Setting up Zabbix on Debian Lenny to monitor Ubuntu Karmic

Jurjen Bokma


We want to use Zabbix to monitor a bunch of PC's running Ubuntu Karmic, but the Zabbix server has to run on Debian Lenny. Lenny has only version 1.4 of Zabbix, which doesn't work well with clients of version 1.6. So we install 1.8 from backports, help Zabbix through the firewalls, and start gathering data...

Procedure 31.  Installing Zabbix 1.8 on Debian Lenny
  1. We need to fetch Zabbix 1.8 from the lenny-backports repository, so we edit /etc/apt/sources.list:

    deb lenny-backports main contrib non-free
    deb-src lenny-backports main contrib non-free           

    We don't want to upgrade all of our packages to the lenny-backports version, so we also create /etc/apt/apt.conf.d/80version:

    APT::Default-Release "lenny";

    Then we update the repository metadata cache, install the keys for the backports repository, and update once more:

    apt-get update
    apt-get install debian-backports-keyring
    apt-get update

  2. apt-get install -t lenny-backports zabbix-server-pgsql zabbix-frontend-php

    Debconf offers to use dbconfig-common to install the database. Use it, because otherwise the database will be created, but the tables will not.

  3. The above installation brings in postgresql-8.1 (8.4?) as a dependency, which is already better than just installing zabbix-frontend-php and having mysql tagging along even though you answer postgres to the question which database you want. But in order to have the database on a database server, we need to transfer it manually. So we dump the database on the zabbix server:

    sudo -u postgres pg_dump zabbix > zabbix.sql

    ... then we create the database on the database server:

    sudo -u postgres createuser zabbix
    sudo -u postgres createdb zabbix -o zabbix
    sudo -u postgres psql
    Welcome to psql 8.3.7, the PostgreSQL interactive terminal.

    Type:  \copyright for distribution terms
    \h for help with SQL commands
    \? for help with psql commands
    \g or terminate with semicolon to execute query
    \q to quit

    postgres=#ALTER USER zabbix WITH PASSWORD 'uioprehjdsnmc';

    Now we can state in /etc/zabbix/zabbix_server.conf that

    ... and in /etc/zabbix/dbconfig.php that:

    $DB["TYPE"]      = "pgsql";
    $DB["SERVER"]    = "";
    $DB["PORT"]      = "0";
    $DB["DATABASE"]  = "zabbix";
    $DB["USER"]      = "zabbix";
    $DB["PASSWORD"]  = "uioprehjdsnmc";
    $ZBX_SERVER      = "";
    $ZBX_SERVER_PORT = "10051";

    For Zabbix to run without complaint, we also need in /etc/php5/conf.d/forZabbix.ini:

    post_max_size = 50M;
    upload_max_filesize = 50M;
    mbstring.func_overload = 2;

    And finally we restart the server and reload the GUI:

    sudo /etc/init.d/zabbix-server restart
    sudo /etc/init.d/apache2 reload

  4. Now that Zabbix is running, we can make it show on the web with this in the Apache config:

    Alias /zabbix/ "/usr/share/zabbix/"
    <Directory "/usr/share/zabbix/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from ::1/128

    First thing to do is to log in on Zabbix with the default username Admin and its password zabbix. Once logged in, a new Super Admin account should be created, and impossible-to-guess passwords should be set on all Super Admin accounts including Admin.

    Then, host groups should be made and discovery rules, and actions should be created that add hosts to these host groups as soon as they are discovered.

  5. In /etc/zabbix/zabbix_agent.conf, the server must be mentioned, and we can set the maximum time per request (from the server) the client may spend on Zabbix:

    The Zabbix daemon that answers the requests from the server must also be configured, in /etc/zabbix/zabbix_agentd.conf:

    And we must restart the daemon for the settings to take effect:

    /etc/init.d/zabbix-agent restart

  6. On the client, ufw is running, so configuring is simple:

    sudo ufw allow proto tcp from to any port 10050

    On the server, plain iptables is at work:

    sudo iptables -A INPUT -s -d -p tcp -m tcp -m state --state NEW -m multiport --dports 10051 -j ACCEPT

    It may be necessary to restart the server after opening up the firewall.


Several weeks later, we see that after a few days, Zabbix has stopped collecting data. The web GUI is very slow (reloading a page takes half a minute or so. The load on the Zabbix server is below 0.4, but all zabbix_server processes are defunct, and when a page is reloaded on the GUI, the PostgreSQL server load that goes to 0.7 or so.

Restarting the Zabbix server doesn't fix the defunct processes, but it does reveal that the CacheSize is too low. According to the manual page on the server config of this version, we can set CacheSize to anywhere between 128K and 1G, the default being 8M. We set it to 32M, and restart the server. Now it's running again. Allegedly, in order to set it any higher, it is necessary to first adjust some kernel parameters with sysctl, like this:

sysctl -w kernel.shmmax=536870912

Or, according to thread 61016 on the Zabbix forum:

Spesific for FreeBSD machine: