Raspberry Pi : monitor the system with Zabbix

In’a previous article, I gave explanations to install the tool called Monitorix. Today is another monitoring tool which we will make the installation : Zabbix

Raspberry Pi Home Server – Monitorer le système avec Zabbix

If you want to choose a tool to monitor your system or just out of curiosity, I'll (try) to offer you a small series of articles with different software.

Here it's Zabbix we will discuss. A little bit more professional than Monitorix, the company offers an open source version installable by all. It is however more complex … And suffice to say it on, its configuration is really not easy and performance aren't really good. So if you have hints of optimizations, I'm interested !

The version used for this article is 2.0.4. Article has been updated for version 2.0.6.

let's go !

  1. Update the system
    apt-get update
  2. Install the following packages
     apt-get install fping sqlite3 libsnmp-dev php5-gd php5-sqlite php5-dev libiksemel-dev libsqlite3-dev libcurl4-openssl-dev php5-curl make
  3. Download Zabbix on the official site. Unpack the archive
  4. Go to the directory of zabbix. Everything will be done from that directory that contains the necessary scripts
  5. Start the configuration
     ./configure --enable-server --enable-agent --with-sqlite3 --with-net-snmp --with-jabber --with-libcurl
  6. Start the compilation
     make
  7. Install
     make install
  8. Add the user zabbix
     adduser zabbix
  9. Create directory for SQLite if had not already installed it
     mkdir /var/lib/sqlite
  10. Create and configure the database in SQLite (Replace /var/lib/sqlite if you installed SQLite elsewhere)
    cd database/sqlite3
    
    sqlite3 /var/lib/sqlite/zabbix.db < schema.sql
    
    sqlite3 /var/lib/sqlite/zabbix.db < images.sql
    
    sqlite3 /var/lib/sqlite/zabbix.db < data.sql
    
    chown -R zabbix:zabbix /var/lib/sqlite
    
    chmod 774 /var/lib/sqlite
    
    chmod 664 /var/lib/sqlite/zabbix.db
  11. Add the user www-data in the zabbix group in order to give the rights to access the database
     adduser www-data zabbix
  12. In the file /usr/local/etc/zabbix_server.conf, change the line
    DBName=zabbix

    by

    DBName=/var/lib/sqlite/zabbix.db
  13. Configure and install startup scripts
     cp misc/init.d/debian/zabbix-server /etc/init.d/
    
     chmod 755 /etc/init.d/zabbix-server
    
     cp misc/init.d/debian/zabbix-agent /etc/init.d/
    
     chmod 755 /etc/init.d/zabbix-agent
  14. If necessary, vous pouvez modifier les scripts pour qu’ils soient compatibles LSB et qu’ils ne rentrent pas en conflit avec d’autres scripts (minidlna chez moi) :Voilà mon message d’erreur :

    insserv: There is a loop between service minidlna and zabbix-server if stopped

    insserv: loop involving service zabbix-server at depth 2

    insserv: loop involving service minidlna at depth 1

    insserv: Stopping zabbix-server depends on minidlna and therefore on system facility `$all’ which can not be true!

    insserv: Stopping zabbix-agent depends on minidlna and therefore it system facility ' $all’ which can not be true!

    insserv: exiting now without changing boot order!

    update-rc.d: error: insserv rejected the script header

    So to solve this problem, the solution is to add the following just after lines #!/bin/sh (so from the line 2) :

    ### BEGIN INIT INFO

    # Provides: zabbix-server

    # Required-Start:

    # Required-Stop:

    # Default-Start: 2 3 4 5

    # Default-Stop: 0 1 6

    # Short-Description: Initialize Zabbix server

    # Description:

    ### END INIT INFO

    Below is the script block /etc/init.d/zabbix-server. You can use the same for /etc/init.d/zabbix-agent, by replacing server by agent.

  15. Add the scripts to the launch
     update-rc.d zabbix-server defaults
    
     update-rc.d zabbix-agent defaults
  16. Install the front end that comes with Zabbix
     mkdir /var/www/zabbix
    
     cp -a frontends/php/* /var/www/zabbix/
    
     chown -R www-data:www-data /var/www/zabbix
  17. Run the scripts manually or reboot Raspberry Pi
     /etc/init.d/zabbix-server start
    
     /etc/init.d/zabbix-agent start
  18. Create a new site zabbix in the nginx configuration (For more information about installing Nginx with PHP support you can see here). The contents of the file /etc/nginx/sites-available/zabbix :
     server {
    
     listen 8090; # You choose !
    
     root /var/www/zabbix;
    
     index index.php;
    
     server_name zabbix;
    
     error_log /var/log/nginx/zabbix_error.log;
    
     access_log /var/log/nginx/zabbix_access.log;
    
     location ~ .php$ {
    
     include/etc/nginx/fastcgi_params;
    
     try_files $uri = 404;
    
     fastcgi_index index.php;
    
     fastcgi_split_path_info ^(.+.php)(/.+)$;
    
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    
     fastcgi_pass unix:/var/run/PHP5-fpm.sock;
    
     }
    
     }
  19. Enable the site
    ln -s /etc/nginx/sites-available/zabbix /etc/nginx/sites-enabled/zabbix
  20. Change the PHP configuration settings in /etc/php5/fpm/php.ini to have a minimum of these values
    max_execution_time = 300
    
    max_input_time = 300
    
    post_max_size = 16M
    
    date.timezone = Europe/Paris
    
    (list of areas : http://fr2.php.net/manual/fr/timezones.php)
  21. Install additional packages to optimize performance
     apt-get install php5-fpm php-pear php-apc php5-gd php5-curl
  22. Restart Nginx and php-fpm
    service nginx restart
    
    service php5-fpm restart
  23. From there it's really easier : connect you to the ip with the correct port number and follow the instructions.Attention on the screen 3 to choose SQlite 3 and specify the path where you installed the DB
Raspberry Pi Home Server – Monitorer le système avec Zabbix

Prerequisites

Raspberry Pi Home Server – Monitorer le système avec Zabbix

The database configuration

Raspberry Pi Home Server – Monitorer le système avec Zabbix

Server configuration

Raspberry Pi Home Server – Monitorer le système avec Zabbix

Configuration summary

Raspberry Pi Home Server – Monitorer le système avec Zabbix

End of installation

Default login is Admin/zabbix (attention to A capital)

Raspberry Pi Home Server – Monitorer le système avec Zabbix

Once installed Zabbix login screen

You then configure the application. You will find all the help on the site of Zabbix.

And as I said at the beginning of article, If you have tracks of optimization, Please do not hesitate !

Like this article ? Bear with me on patreon!

You may also like...