Linux : Monitoring And supervision with Zabbix

Here is some notes of my own Zabbix monitoring system installation (debian based). It has been done since a while now, but I never took the time to finalize this post. However, it can still be usefull as not much (nothing ?) has changed regarding activities to do…

Base Install

Server Part

apt-get install apache2 mysql snmp zabbix-agent zabbix-frontend-php zabbix-server-mysql

Snmp is of course only usefull if you have things that support it (my administrable switch does)…

Then follow instruction on /usr/share/doc/zabbix-server-mysql/README.Debian

In /etc/zabbix/zabbix_server.conf,

  • I comment out “LogFile” to use Syslog as I centralise all my logs with rsyslog
  • I set Housekeeping to 24 (small home network with less than 10 servers)
  • LogSlowQuery=10

Enable zabbix-server in /etc/default/zabbix-server and launch it:

/etc/init.d/zabbix-server start

Make the admin console available through an alias in apache and restrict access to some IP addresses (vhost should work too) :

<Directory /usr/share/zabbix>
     Options FollowSymLinks
     AllowOverride None
     Order allow,deny
     Allow from a.b.c
<IfModule mod_alias.c>
    Alias /zabbix /usr/share/zabbix

Put this in sites-available instead (I prefer that over the conf directory, then activate the site (either a2ensite or simple ln -s) and finaly restart apache (apachectl graceful).

Then, go to https://<server>/zabbix and follow the instructions.
At the end of the procedure, download and copy the generated configuration file to /etc/zabbix and set restrictive permission on it (db password in clear text inside) :

chown root:www-data /etc/zabbix/zabbix_server.conf
chmow 640 /etc/zabbix/zabbix_server.conf

Be careful: you may need to increase the number of MySQL connections (max_connection parameter) if you already have other services that use it (zabbix server + Php front-end eat up at least 10 connections for a single user).

Also, mysqltunner can be very usefull to check MySQL settings.

Client Part (agent)

If all is up and running, zabbix-agent must be installed on all server that need to be monitored (apt-get install zabbix-agent). Then :

  • set hostname
  • set zabbix server ip
  • optionally comment out LogFile to use syslog (rsyslog in my case)
  • update /etc/hosts.allow (eg: zabbix_agentd:<zabbix server ip>)

Custom Monitoring


if monitoring of https services fail, change the standard item from “net.tcp.service[https]” to “net.tcp.service[tcp,,443]”


You can find great bash scripts to monitor apache variables here :

copy them on /usr/share/zabbix-scripts/ and give proper permissions

chmod 770 /usr/share/zabbix-scripts/
chown zabbix /usr/share/zabbix-scripts/


Example can be found here :

If you want  max supported connection on your screens, add the following “userparameter” :

UserParameter=nginx.maxconnection[*],grep -o "worker_[[:alpha:]]*[[:blank:]]*[[:digit:]]*[[:blank:]]*;" $1 | tr -d '\n' | tr ';' ' ' | awk '{print $$2 * $$4}'

In case it may help, my own Nginx template : zbx_export_templates



Create a user for zabbix that is allowed to check MySQL processes. For example :


Then protect the file : owned by the user and group your zabbix agent is running on behalf of and proper chmod :

chown zabbix:zabbix userparameter_mysql.conf
chmod 400 userparameter_mysql.conf

You can also set a home dir for zabbix user, and set user and password in ~/.my.cnf


See :

Weekly and monthly Screen summary by e-mail

You can find a nice Perl script that send an e-mail with all of your favorites Zabbix screen here :

To make it work as, for example, /usr/share/zabbix-scripts/ you need the following :

apt-get install curl
mkdir /usr/share/zabbix-scripts
/usr/bin/perl -MCPAN -e 'install DateTime'
/usr/bin/perl -MCPAN -e 'install MIME::Lite'
chmod 700 /usr/share/zabbix-scripts/

You need also to adapt parameters at the begening of the file regarding Zabbix user and database

In addition, if you are using Zabbix 2.2.1,  change the line 62 (“$cmglogin..”.) by :

my $cmdLogin = `curl -s -c $cookie -d 'name=$login&amp;password=$pass&amp;enter=Sign%20in' $zabbix/index.php`;

Leave a Reply

Your email address will not be published. Required fields are marked *