Skip to content

Instantly share code, notes, and snippets.

@kmonticolo
Last active August 30, 2018 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmonticolo/04e64e585d3b501f7378d183907451d8 to your computer and use it in GitHub Desktop.
Save kmonticolo/04e64e585d3b501f7378d183907451d8 to your computer and use it in GitHub Desktop.
zabbix_proxy
fresh openbsd62 installation with comp xbase xfont (x for java)
/etc/rc.d/ntpd start
rcctl enable ntpd
pkg_add wget zabbix-agent
rcctl enable zabbix_agentd
modify /etc/zabbix/zabbix_agentd.conf
# egrep '(^LogFile|^Server)' /etc/zabbix/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=172.31.222.1
ServerActive=127.0.0.1
rcctl restart zabbix_agentd
# proxy installation
pkg_add nmap fping arping mariadb-server jdk javaPathHelper
# jdk is needed for java-proxy
export JAVA_HOME=/usr/local/jdk-1.8.0/
echo export JAVA_HOME=/usr/local/jdk-1.8.0/ >> /root/.profile
javaPathHelper -c jdk
export PATH=$PATH:$JAVA_HOME/bin/
which javac
echo export PATH=$PATH:$JAVA_HOME/bin/ >> /root/.profile
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.4.7/zabbix-3.4.7.tar.gz/download
mv download zabbix-3.4.7.tar.gz
tar zxf zabbix-3.4.7.tar.gz
cd zabbix-3.4.7/
./configure --enable-proxy --enable-java --with-mysql
make install
ls /usr/local/sbin/zabbix_proxy
cd /etc/rc.d/
cp zabbix_agentd zabbix_proxy
sed -i 's/agentd/proxy/g' zabbix_proxy
vi /usr/local/etc/zabbix_proxy.conf
uncomment and change :
Server=
# User=zabbix to User=_zabbix in 562
uncomment and change # FpingLocation=/usr/local/sbin/fping
# setup MySQL
mkdir -p /var/mysql
chown -R _mysql:_mysql /var/mysql
mysql_install_db
rcctl enable mysqld
rcctl start mysqld
rcctl check mysqld
/usr/local/bin/mysql_secure_installation
# configure db for proxy
follow:
https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages/server_installation_with_mysql
use zabbix_proxy instead of zabbix
# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.0.32-MariaDB OpenBSD port: mariadb-server-10.0.32v1
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix_proxy character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye
vi /usr/local/etc/zabbix_proxy.conf
reconfigure: DBPassword=zabbix
mysql zabbix_proxy -u zabbix -p < /root/zabbix-3.4.7/database/mysql/schema.sql
/etc/rc.d/zabbix_proxy start
/etc/rc.d/zabbix_proxy check
rcctl enable zabbix_proxy
add PATH=$PATH:/usr/local/jdk-1.8.0/bin/ /usr/local/sbin/zabbix_java/startup.sh
to /etc/rc.local
add IP `cat /etc/myname` to /etc/hosts
add to root crontab:
* * * * * /etc/rc.d/zabbix_proxy check >/dev/null || ( /etc/rc.d/zabbix_proxy start && logger zabbix_proxy_RESTART )
############################# testinfra
pkg_add py-pip
ln -sf /usr/local/bin/pip2.7 /usr/local/bin/pip
ln -sf /usr/local/bin/python2.7 /usr/local/bin/python
ln -sf /usr/local/bin/python2.7-2to3 /usr/local/bin/2to3
ln -sf /usr/local/bin/python2.7-config /usr/local/bin/python-config
ln -sf /usr/local/bin/pydoc2.7 /usr/local/bin/pydoc
pip install testinfra
# cat test_zabbix_proxy.py
def test_uname_output(Command):
command = Command('uname -s')
assert command.stdout.rstrip() == 'OpenBSD'
assert command.rc == 0
def test_passwd_file(host):
passwd = host.file("/etc/passwd")
assert passwd.contains("root")
assert passwd.user == "root"
assert passwd.group == "wheel"
assert passwd.mode == 0o644
def test_zabbix_user_exists(User):
'''Check user exists'''
user = User('_zabbix')
assert user.exists
def test_zabbix_group_exists(Group):
'''Check group exists'''
group = Group('_zabbix')
assert group.exists
def test_zabbix_agent_package_exists(host):
package = host.package("zabbix-agent")
assert package.is_installed
def test_arping_package_exists(host):
package = host.package("arping")
assert package.is_installed
def test_fping_package_exists(host):
package = host.package("fping")
assert package.is_installed
def test_jdk_package_exists(host):
package = host.package("jdk")
assert package.is_installed
def test_mariadbclient_package_exists(host):
package = host.package("mariadb-client")
assert package.is_installed
def test_mariadbserver_package_exists(host):
package = host.package("mariadb-server")
assert package.is_installed
def test_nmap_package_exists(host):
package = host.package("nmap")
assert package.is_installed
# services
def test_mysql_service_exists(host):
service = host.service("mysqld")
assert service.is_running
assert service.is_enabled
def test_ntpd_service_exists(host):
service = host.service("ntpd")
assert service.is_running
assert service.is_enabled
#zabbix_agentd zabbix_proxy
def test_zabbix_agentd_service_exists(host):
service = host.service("zabbix_agentd")
assert service.is_running
assert service.is_enabled
def test_zabbix_proxy_service_exists(host):
service = host.service("zabbix_proxy")
assert service.is_running
assert service.is_enabled
# processes
def test_zabbix_proxy_process_exists(host):
process = host.process.filter(user="_zabbix", comm="zabbix_proxy")
def test_zabbix_java_process_exists(host):
process = host.process.get(user="root", comm="java")
def test_command_output(Command):
command = Command('grep startup.sh /etc/rc.local')
assert command.stdout.rstrip() == 'PATH=$PATH:/usr/local/jdk-1.8.0/bin/ /usr/local/sbin/zabbix_java/startup.sh'
assert command.rc == 0
def test_port_zabbix_agent_output(Command):
command = Command('netstat -an|grep ^tcp.*\.10050.*LIST')
assert command.rc == 0
def test_port_zabbix_proxy_output(Command):
command = Command('netstat -an|grep ^tcp.*\.10051.*LIST')
assert command.rc == 0
def test_port_zabbix_java_proxy_output(Command):
command = Command('netstat -an|grep ^tcp.*\.10052.*LIST')
assert command.rc == 0
def test_port_mysql_output(Command):
command = Command('netstat -an|grep ^tcp.*127.0.0.1.3306.*LIST')
assert command.rc == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment