So I will add some details on NS installation of the Zabbix Server, trying to share some more information just because it’s Christmas time and I feel a good boy
@mrmarkuz tutorial at the beginning of the thread is quite fine, still I do think some additions may be interesting.
Zabbix Server daemon inside NethServer WebGUI
Integration inside NS WebGUI (under network services, adding exclusions to the firewall) is quite easy:
mkdir -p /etc/e-smith/db/configuration/defaults/zabbix-server
echo "service" > /etc/e-smith/db/configuration/defaults/zabbix-server/type
echo "enabled" > /etc/e-smith/db/configuration/defaults/zabbix-server/status
echo "10051" > /etc/e-smith/db/configuration/defaults/zabbix-server/TCPPort
echo "public" > /etc/e-smith/db/configuration/defaults/zabbix-server/access
db configuration set zabbix-server service status enabled TCPPort 10051 access public
signal-event runlevel-adjust && signal-event firewall-adjust
Adding SNMP support and MIBs
yum install net-snmp-utils nethserver-net-snmp
This would install common MIBs usually used in some templates. Developing custom templates (e.g. for Zyxel Switches) using MIBs is much more easier (because they describe each OID and assigns to some of them strings as names of the OID). If you use OID names, you need to install a copy of the MIB you used in development in the folder /usr/share/snmp/mibs
of the Zabbix Server.
Using Postgres as a backend (instead of MariaDB/MySQL)
useradd -m -d /var/lib/zabbix -s /bin/bash zabbix
passwd zabbix
yum install nethserver-postgresql
echo "alter role postgres password 'secret'" | sudo -u postgres psql
echo "create role zabbix with CREATEDB LOGIN PASSWORD 'secret'" | sudo -u postgres psql
echo "create database zabbix owner zabbix" | sudo -u postgres psql
echo "local\tall\t\tzabbix\t\t\t\tident" >> /etc/e-smith/templates/var/lib/pgsql/data/pg_hba.conf/20auth
# Previous line permits to the Unix user zabbix to authenticate without passing the password.
signal-event nethserver-postgresql-update
yum install --enablerepo=zabbix zabbix-server-pgsql
zcat $(rpm -ql zabbix-server-pgsql | grep create.sql.gz) | sudo -u zabbix psql zabbix
# Configure /etc/zabbix/zabbix_server.conf according to @mrmarcuz guide above
systemctl restart zabbix-server
# Frontend accordingly installed with:
yum install --enablerepo=zabbix php-pgsql zabbix-web zabbix-web-pgsql
Automatic creation of the frontend configuration
You may customize the file /etc/zabbix/web/zabbix.conf.php
to automatically configure the frontend (so to skip the first wizard). For example, here’s a template from our ansible playbook:
<?php
// Zabbix GUI configuration file.
global $DB;
$DB['TYPE'] = 'POSTGRESQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = '{{ postgresql_username }}';
$DB['PASSWORD'] = '{{ postgresql_passwd }}';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
Placeholders should be quite clear to understand
Zabbix agent
If you use other NethServers in your networks (as we do ), you may want to use Zabbix Agent to monitor them. Configure it like this:
# Following lines create a unix 'zabbix' user which can run any program as root
useradd -m -d /var/lib/zabbix -s /bin/bash zabbix
passwd zabbix # use strong password!
echo "zabbix ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/zabbix
chmod 0440 /etc/sudoers.d/zabbix
yum localinstall http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install --enablerepo=zabbix zabbix-agent
# Edit zabbix_agentd.conf file - see below
# Integrating the Agent within NethServer GUI
mkdir -p /etc/e-smith/db/configuration/defaults/zabbix-agent
echo "service" > /etc/e-smith/db/configuration/defaults/zabbix-agent/type
echo "enabled" > /etc/e-smith/db/configuration/defaults/zabbix-agent/status
echo "10050" > /etc/e-smith/db/configuration/defaults/zabbix-agent/TCPPort
echo "public" > /etc/e-smith/db/configuration/defaults/zabbix-agent/access
db configuration set zabbix-agent service status enabled TCPPort 10050 access public
signal-event runlevel-adjust && signal-event firewall-adjust
systemctl restart zabbix-agent
Agent configuration file (/etc/zabbix/zabbix_agentd.conf
) is well commented and documentation online is quite complete, so be careful to correctly configure at least the following variables:
Server={{ your_zabbix_server_IP }}
ServerActive={{ your_zabbix_server_IP }}
User=zabbix
Last one is to drop permissions on zabbix-agent
daemon to run as zabbix Unix user. Unfortunately we didn’t develop a NethServer GUI to configure base parameters, this may be a good addition.
Caution Also your Zabbix Server should have its own Agent, so you may follow the same steps! Server
and ServerActive
in this case can be leaved at 127.0.0.1
.
Next round I will share instructions on how to monitor NS backups using the agent, a script, some UserParameters and a custom template, and the configuration for the Zabbix Proxy Just hope this is not coming next Christmas