Zabbix

From ArchWiki

Zabbix is a full-featured monitoring solution for larger networks. It can discover all kind of networking devices using different methods, check machine states and applications, sending pre-defined alarm messages and visualize complex data correlations.

Server setup

Installation

Server Installation

Install the zabbix-server package. This includes the necessary scripts for use with MariaDB or PostgreSQL.

Database Installation

Install either the mariadb package or the postgresql package.

Frontend Installation

Install the zabbix-frontend-php package. You should choose a web server with PHP support, e.g.:

You can also choose one of the servers found in Category:Web server.

Configuration

Symlink the Zabbix web application directory to your http document root, e.g.:

$ ln -s /usr/share/webapps/zabbix /srv/http/zabbix

To get Apache working out-of-the-box, you need to enable PHP integration:

Adjust following variables in /etc/php/php.ini:

extension=bcmath
extension=gd
extension=sockets
extension=mysqli
extension=gettext
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = "UTC"
Tip: If using php-fpm and mod_proxy_fcgi, you may need to restart php-fpm.service.

Database Initialization

MariaDB

In this example, we create on localhost a MariaDB database called zabbix for the user zabbix identified by the password test and then import the database templates. This connection will be later used by the Zabbix server and web application.

Note: On a production system, the password should be changed to something more secure.

If your MariaDB installation uses a root account with a password, use the following:

$ mariadb -u root -p -e "create database zabbix character set utf8 collate utf8_bin"
$ mariadb -u root -p -e "grant all on zabbix.* to zabbix@localhost identified by 'test'"

If your MariaDB installation uses a root account without a password, use the following:

# mariadb -e "create database zabbix character set utf8 collate utf8_bin"
# mariadb -e "grant all on zabbix.* to zabbix@localhost identified by 'test'"

Use the following to import the database templates:

$ mariadb -u zabbix -p -D zabbix < /usr/share/zabbix-server/mysql/schema.sql
$ mariadb -u zabbix -p -D zabbix < /usr/share/zabbix-server/mysql/images.sql
$ mariadb -u zabbix -p -D zabbix < /usr/share/zabbix-server/mysql/data.sql

PostgreSQL

For PostgreSQL, these commands will create a database zabbix for user zabbix, which are the default settings in zabbix_server.conf, then import the schema and initial data:

$ createuser zabbix
$ createdb zabbix -O zabbix
$ cat /usr/share/zabbix-server/postgresql/{schema,images,data}.sql | psql -U zabbix -d zabbix

Database Configuration

Now edit /etc/zabbix/zabbix_server.conf with the database settings:

/etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=test
LogType=system

ICMP/ping discovery

To use ICMP discovery (e.g. ping) in Zabbix, install the fping package.

Starting

If you are using MariaDB, enable and start the zabbix-server-mysql.service unit, or if you are using PostgreSQL, the zabbix-server-pgsql.service unit.

Access Zabbix via your local web server, e.g.: http://localhost/zabbix/, and start the installation wizard.

The default username is Admin and password zabbix.

See appendix for a link to the official documentation, which explains all further steps in using it.

Agent setup

Installation

Install zabbix-agent for each monitoring target, including your monitoring server where zabbix-server is installed. zabbix-server no longer includes zabbix-agent.

Configuration

Simply edit the zabbix_agentd.conf and replace the server variable with the IP of your monitoring server. Only servers from this/these IP will be allowed to access the agent.

Server=<IP of Zabbix server>
ServerActive=<IP of Zabbix server>

Further make sure the port 10050 on your device being monitored is not blocked and is properly forwarded.

Starting

Enable and start the zabbix-agent.service unit.

Tips and tricks

Debugging a Zabbix agent

On the client site, you can check the state of an item like this:

$ zabbix_agentd -t hdd.smart[sda,Temperature_Celsius]

On the server/monitoring site, try this:

$ zabbix_get -s host -k hdd.smart[sda,Temperature_Celsius]

Monitor Arch Linux system updates

Here is an approach on how to monitor your Arch Linux clients for available system update using a custom UserParameter:

/etc/zabbix/zabbix_agentd.conf
Include=/etc/zabbix/zabbix_agentd.conf.d/*.conf
/etc/zabbix/zabbix_agentd.conf.d/archlinuxupdates.conf
UserParameter=archlinuxupdates,checkupdates | wc -l

You have to restart zabbix-agentd to apply the new configuration. The keyword for the item you later use in the web frontend is archlinuxupdates. It returns an integer representing the count of available updates.

Troubleshooting

Error "Specified key was too long; max key length is 767 bytes"

While importing the databases, you might get this error message. In order to solve this, you will have to change the code page configuration for your MariaDB database: MariaDB#Using UTF8MB4.

See also