Let`s learn what is going on with Raspberry Pis in home network

Since I have several Raspberry Pi’s at home, I figured out it would be cool to know how they perform while I am not using them. I decided to install Zabbix on one of them. If you don’t know what Zabbix is, it is an open source monitoring solution for networks and applications.

Let`s install dependencies required for compiling Zabbix from source.

sudo apt-get install libxml2-dev libsnmp-dev libcurl4-openssl-dev

I have decided to use PostgreSQL, even though MySQL is available as well, but the performance on Raspberry Pi is significant better with PostgreSQL. Raspbian Wheezy has in repositories version 9.1 available, which is older but sufficient

sudo apt-get install postgresql-9.1 postgresql-server-dev-9.1

If you want to use Zabbix with MySQL (which I do NOT recommend) install additional library

sudo apt-get libmysqld-dev

Lets create zabbix user

sudo adduser --no-create-home zabbix

We need to login to database as postgres

sudo -s
su postgres

Connect to template1, create new database and grant access to zabbix user

\c template1

Switch back to pi user and download latest Zabbix from official page copy to Raspberry Pi and extract it

tar -zxvf zabbix-2.4.5.tar.gz

We need to import database schema and data, so go to postgresql directory and import files in this order

cd database/postgresql
psql -U zabbix zabbix < schema.sql
psql -U zabbix zabbix < images.sql
psql -U zabbix zabbix < data.sql

In case you want it to install to MySQL, just switch import directory postgresql to mysql and import files in the same order. Performance tuning tip for MySQL is to use MyISAM instead of InnoDB as storage engine, it will lower the requirements for CPU when running, but be aware that this step is NOT recommended by Zabbix.

Return back to Zabbix root directory and start compiling with this options

./configure --enable-server --enable-agent --with-postgresql --with-net-snmp --with-libcurl --with-libxml2
sudo make install

For MySQL installation change from —-with-postgresql to —-with-mysql

We need to set database name DBName, user DBUser and password DBPassword in file zabbix_server.conf

sudo vi /usr/local/etc/zabbix_server.conf

Update zabbix_agentd.conf with Server IP address set to

sudo vi /usr/local/etc/zabbix_agentd.conf

Copy daemons into system

sudo cp misc/init.d/debian/zabbix-server /etc/init.d/
sudo cp misc/init.d/debian/zabbix-agent /etc/init.d/

Modify daemons and add LSB tags so they are proper Debian init scripts and we can manipulate them with service command (analogically do the same for agent script)


# Provides:          zabbix_server
# Required-Start:    $all
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Zabbix server
# Description:       Zabbix server daemon

Setup on boot daemon start and start both daemons

sudo chmod 755 /etc/init.d/zabbix-server
sudo update-rc.d zabbix-server defaults
/etc/init.d/zabbix-server start

sudo chmod 755 /etc/init.d/zabbix-agent
sudo update-rc.d zabbix-agent defaults
/etc/init.d/zabbix-agent start

It is possible to have the PHP web interface on the same Raspberry Pi, however I have tested on first version and it works, but the performance is slow and sometimes it really overload the whole OS. I managed to make load higher than 20 with draining whole RAM and SWAP, so my recommendation is to install it on other machine, but if that is not an option for you, follow this steps to install Zabbix web interface on your Raspberry Pi

We need to have Nginx and PHP installed, I have already talked about it in older blog post. We also need install dependencies required for PHP

sudo apt-get install php5-gd php5-pgsql

Create directory where webgui will be stored and set web server owner

sudo mkdir /var/www/zabbix
sudo cp -a frontends/php/* /var/www/zabbix/
sudo chown -R www-data /var/www/zabbix

We have to update php.ini so it matches the Zabbix requirements

sudo vi /etc/php5/fpm/php.ini

Make sure these values are set:

max_execution_time = 300
max_input_time = 300
post_max_size = 16M
date.timezone = [supported timezone](http://php.net/manual/en/timezones.php)

PHP has to be reloaded in order to our changes take effects

sudo /etc/init.d/php5-fpm restart

We also need to create site-available configuration file

server {
    listen 80; # listen for ipv4
    server_name zabbix; # Add your Raspberry Pi IP address here

    access_log /var/log/nginx/zabbix.access.log;
    error_log /var/log/nginx/zabbix.error.log;

    root /var/www/zabbix;

    location / {
        root /var/www/zabbix;
        index index.php index.html index.htm;

    # Parse all .php file in the /var/www/zabbix directory
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/zabbix$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_intercept_errors on;
        fastcgi_ignore_client_abort off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;

    # Disable viewing .htaccess &amp; .htpassword
    location ~ /\.ht {
        deny all;

Reload Nginx to read new configuration

sudo /etc/init.d/nginx restart

Open browser and visit your Raspberry Pi and finish configuration in browser