msgbartop
MAC OS X, Linux, Windows and other IT Tips and Tricks
msgbarbottom

22 May 10 Installing Zabbix 2.2.6 on Debian Squeeze

Debian Squeeze has still the Zabbix 1.8.2, if you want the install the 2.2.6, then one solution is to follow these instructions, the other is to do the hard work all the way(not shown here :-):

The easy way:


Zabbix has now Binary packages ready for Debian Wheezy to install:
Reference:
//www.zabbix.com/documentation/2.0/manual/installation/install_from_packages
Steps for version 2.2.6:
wget //repo.zabbix.com/zabbix/2.0/debian/pool/main/z/zabbix-release/zabbix-release_2.0-1wheezy_all.deb
dpkg -i zabbix-release_2.0-1wheezy_all.deb

Edit /etc/apt/sources.list.d/zabbix.list and replace the 2.0 for 2.2 as follows:
deb //repo.zabbix.com/zabbix/2.2/debian wheezy main
deb-src //repo.zabbix.com/zabbix/2.2/debian wheezy main

Update the DPKG db:
apt-get update
Now find out which packages are available and install the one you need:
apt-cache search zabbix
To install the server:
apt-get install zabbix-server-mysql
To install the agent (should be installed in every Server to monitor)
apt-get install zabbix-agent
Edit the configuration file and add the IP address of the host where the Zabbix server runs:
vim /etc/zabbix/zabbix_agentd.conf
#Server=127.0.0.1
Server=192.168.10.35

Note: You can also download each package individually from this URL:
//repo.zabbix.com/zabbix/2.2/debian/pool/main/z/zabbix/

EXTRAS:
In order to monitor some extra things in the target servers, you can do it by expanding the functionality of the zabbix-agent as follows:
Example to monitor Apache’s activities:
apt-get install libwww-perl
Edit /etc/zabbix/zabbix-agentd.conf and add the following lines at the end of the file:
# APACHE
# Note: make sure: apt-get install libwww-perl' otherwise you may get : Can't locate LWP/Simple.pm
UserParameter=apache2.total_accesses,/etc/zabbix/zabbix_apache2.pl|cut -f1 -d":"
UserParameter=apache2.total_kbytes,/etc/zabbix/zabbix_apache2.pl|cut -f2 -d":"
UserParameter=apache2.cpuload,/etc/zabbix/zabbix_apache2.pl|cut -f3 -d":"
UserParameter=apache2.uptime,/etc/zabbix/zabbix_apache2.pl|cut -f4 -d":"
UserParameter=apache2.reqpersec,/etc/zabbix/zabbix_apache2.pl|cut -f5 -d":"
UserParameter=apache2.bytespersec,/etc/zabbix/zabbix_apache2.pl|cut -f6 -d":"
UserParameter=apache2.bytesperreq,/etc/zabbix/zabbix_apache2.pl|cut -f7 -d":"
UserParameter=apache2.busyworkers,/etc/zabbix/zabbix_apache2.pl|cut -f8 -d":"
UserParameter=apache2.idleworkers,/etc/zabbix/zabbix_apache2.pl|cut -f9 -d":"
UserParameter=apache2.totalworkers,/etc/zabbix/zabbix_apache2.pl|cut -f10 -d":"

Script needed for this above extension to function:
Save it as /etc/zabbix/zabbix_apache2.pl
#!/usr/bin/perl
#
## Zabbix_Apache2.pl
## Versions 0.99
## Updates here: //www.unix.com/web-programming-web-2-0-mashups/103922-zabbix-template-perl-script-monitoring-apache2.html
## //www.unix.com/
#
use LWP::Simple;
use strict;
#
my($url)="//localhost/server-status?auto";
my($server_status)=get($url);
my($total_accesses,$total_kbytes,$cpuload,$uptime, $reqpersec,$bytespersec,$bytesperreq,$busyworkers, $idleworkers,$totalworkers);
#
if (! $server_status) {
print "Can't access $url\nCheck apache configuration\n\n";
exit(1);
}
#
$total_accesses = $1 if ($server_status =~ /Total\ Accesses:\ ([\d|\.]+)/ig)||0;
$total_kbytes = $1 if ($server_status =~ /Total\ kBytes:\ ([\d|\.]+)/gi);
$cpuload = $1 if ($server_status =~ /CPULoad:\ ([\d|\.]+)/gi);
$uptime = $1 if ($server_status =~ /Uptime:\ ([\d|\.]+)/gi);
$reqpersec = $1 if ($server_status =~ /ReqPerSec:\ ([\d|\.]+)/gi);
$bytespersec = $1 if ($server_status =~ /BytesPerSec:\ ([\d|\.]+)/gi);
$bytesperreq = $1 if ($server_status =~ /BytesPerReq:\ ([\d|\.]+)/gi);
$busyworkers = $1 if ($server_status =~ /BusyWorkers:\ ([\d|\.]+)/gi);
$idleworkers = $1 if ($server_status =~ /IdleWorkers:\ ([\d|\.]+)/gi);
$totalworkers = $busyworkers + $idleworkers;
#
printf "%i:%i:%.2f:%i:%.2f:%.2f:%.2f:%i:%i:%i\n",$total_accesses,$total_kbytes,$cpuload,$uptime,$reqpersec,$bytespersec,$bytesperreq,$busyworkers,$idleworkers,$totalworkers;
exit(0);

# Make the script runnable
chmod 755 /etc/zabbix/zabbix_apache2.pl
IMPORTANT: For this script to work you need to make sure you Apache is configured to deliver a full Extended status with the URL:
//localhost/server-status

Configuration in Zabbix-server:
In Zabbix server interface you create a new item in the ‘linux’ template as follows:

The hard manual way


Using the source code and manually compile it.
Principle:
For convenience, we install the Debian’s older Zabbix version and then do the updating and modifications necessary.
Note 1: Zabbix authors are saying that older zabbix-agent daemon (like with Debian) is compatible with the new Zabbix Server, therefore it should not be necessary to update the agent. BUT my experience is that the newer agent brings definitely improvements specially in special remote commands controls. So I suggest you always use the same version for agent and the server.

– Install the regular Zabbix packages from Debian repository and some extra needed packages for the compiling of Version 2.2.4:
apt-get install zabbix-agent zabbix-frontend-php zabbix-server-mysql build-essential libmysqlclient15-dev libcurl4-openssl-dev libsnmp-dev snmp snmpd php5-mysql
pkg-config autoconf automake

– Download the new Zabbix 2.2.6 source:
mkdir -p /root/src/zabbix
cd /root/src/zabbix
wget //prdownloads.sourceforge.net/zabbix/zabbix-2.2.6.tar.gz

– Untar the file:
tar fvxz zabbix-2.2.6.tar.gz
cd zabbix-2.2.6

– Run the configure command:
Note: if any error occur, look through apt-cache search commands to find the missing -dev packages, and re-run the following configure command till it goes to the end successfully.
At the end it will present you with the configuration parameters ready to be compiled:
./configure --enable-server --enable-agent --with-mysql --with-libcurl --with-net-snmp
– If all OK then compile it:
(This will compile and install Zabbix binaries in /usr/local/bin, /usr/local/sbin, /usr/local/etc)
make install
Note: Make sure you have got pkg-config and autoconf installed and run the command ‘autoreconf -fi’, or you will receive an error like this:
./configure: line 8092: syntax error near unexpected token `IKSEMEL,iksemel,'
FRONT END(Web interface)
– Rename or delete the installed Debian zabbix front end PHP files:
mv /usr/share/zabbix /usr/share/zabbix.debian
– Copy recursively the PHP frontend files into the original:
mkdir /usr/share/zabbix/
cp -a ./frontends/php/* /usr/share/zabbix/

Rename and edit the Zabbix front end configuration file and enter the correct parameters for Mysql access.
mv /usr/share/zabbix/conf/zabbix.conf.php.example /usr/share/zabbix/conf/zabbix.conf.php
vim /usr/share/zabbix/conf/zabbix.conf.php

Make the front-end configuration directory writable by Apache user(www-data)
(Needed only for the initial configuration via the front-end)
chown -R www-data /usr/share/zabbix/conf
Add the recommended (but optional)following entries in /etc/services:
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-trapper 10051/udp # Zabbix Trapper

– Create a new MySQL user called zabbix (incl. his password) and give the full access rights of database zabbix to this zabbix user. (in table: db)

– Reload the databases access rights through the SQL command:
FLUSH PRIVILEGES;

– Create a database called zabbix (or delete the old one and create a new one) in MySQL: (using mysql client or phpMyAdmin)
Bash shell> mysql -u'username' -p'password'
mysql> create database zabbix character set utf8;
mysql> quit;
Bash shell> cd create/schema
Bash shell> cat mysql.sql | mysql -u'username' -p'password' zabbix
Bash shell> cd ../data
Bash shell> cat data.sql | mysql -u zabbix -p'password' zabbix
Bash shell> cat images_mysql.sql | mysql -u zabbix -p'password' zabbix

– Start the zabbix frontend through the browser and follow the instructions for installation.
You might have to change some PHP parameters in /etc/php5/apache2/php.ini to match the requirements.eg.
//www.myzabbix.com/zabbix

– Modify the above init scripts by changing the binary files paths to:
/etc/init.d/zabbix-server: DAEMON=/usr/local/sbin/zabbix_server
/etc/init.d/zabbix-agent: DAEMON=/usr/local/sbin/zabbix_agentd

Replace the Debian Zabbix Server config file:
mv /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.debian
ln -s /usr/local/etc/zabbix_server.conf /etc/zabbix/zabbix_server.conf

Configure the following zabbix server configuration file regarding the MySQL login data in:
/etc/zabbix/zabbix_server.conf
Replace the Debian Zabbix agent config file:
mv /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.debian
ln -s /usr/local/etc/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf

– Make the appropriate changes in the zabbix agent configuration file.
(especially the LogFile, Server and PidFile paramerters)
vim /etc/zabbix/zabbix_agentd.conf

Start both the daemons:
/etc/init.d/zabbix-server start
/etc/init.d/zabbix-agent start

Go to the web interface and try to login as ‘admin’
Note: If you have difficulties logging in as ‘admin’, you might want to change the alias of the administrator to ‘admin’ and his password in MD5 format using phpMyAdmin in the table: ‘users’.
In case of more difficulties you might want to check this link:
//www.zabbix.com/documentation/2.0/manual/installation/installation_from_source

– That should be it. Continue everything else via the web interface.

Compiling and Installing Zabbix agent only on zabbix clients(monitored servers).

Note: Although the documentation says that the older agents are compatible with the new version of zabbix server, I had some quircks that got resolved only when I compiled and installed the latest version of zabbix-agent from sources as follows.
– Install the zabbix-agent and build-essential from Debian:
apt-get install build-essential zabbix-agent
– Stop the zabbix-agent daemon
/etc/init.d/zabbix-agent stop
– Download the new Zabbix 2.2.4 source:
mkdir -p /root/src/zabbix
cd /root/src/zabbix
wget //prdownloads.sourceforge.net/zabbix/zabbix-2.2.4.tar.gz

– Untar the file:
tar fvxz zabbix-2.2.4.tar.gz
cd zabbix-2.2.4
autoreconf -fi

– Run the configure command:
Note: if any error occur, look through apt-cache search commands to find the missing -dev packages, and re-run the following configure command till it goes to the end successfully. At the end it will present you with the configuration parameters ready to be compiled:
./configure --enable-agent
– If all OK then compile it:
(This will compile and install Zabbix binaries in /usr/local/bin, /usr/local/sbin, etc.)
make install
Note: If errors occur, it might be because you are using an already compiled copy of the zabbix source directory. If that is the case, just issue the command:
make clean
make install

– Modify the zabbix-agent start script.
vim /etc/init.d/zabbix-agent
make the following changes on line 10:
From:
DAEMON=/usr/sbin/zabbix_agentd
To:
DAEMON=/usr/local/sbin/zabbix_agentd

– Modify the zabbix-agentd configuration file:
vim /etc/zabbix/zabbix_agentd.conf
Enter the IP of the server.(eg. Zabbix server is having the IP:12.34.56.78)
Server=12.34.56.78
If more than one server need to call this agent then add the IP list separated with commas’,’ eg.
Server=12.34.56.78,192.168.1.45

– Add the following lines in /etc/services:
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-trapper 10051/udp # Zabbix Trapper

Replace the Debian Zabbix agent config file:
mv /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.debian
ln -s /usr/local/etc/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf

– Make the appropriate changes in the zabbix agent configuration file.
(especially the LogFile, Server PidFile paramerters)
vim /etc/zabbix/zabbix_agentd.conf

– Start the zabbix-agentd
/etc/init.d/zabbix-agent start

LAST UPDATE::
Zabbix web site offers now the latest version of Zabbix server/Agent/Frontend 2.0.5 as Debian package. After downloading the .deb files and tried to install them with the dpkg -i command you will be prompted with an error of missing a package(s). Just install this/these package(s) with apt-get install command and all will be installed automatically. Remember that you need to download and install 3 .deb files fromt the site: the Server, the Agent and the Web Frontend.

Enjoy the monitoring with Zabbix.

Reader's Comments

  1.    

    Hi, I followed your guide, and it almost worked perfectly on a out-of-box Lenny install. You need to add the following package so the frontend installation works : “php5-mysql”Many thanks for that tutorial, and thanks for sharing ! you rox 🙂

    Reply to this comment
  2.    

    Thanks for the comment. I just added it.

    Reply to this comment
  3.    

    Another thing ; in /etc/services, the description should be prefixed by a # :zabbix-agent 10050/tcp # Zabbix Agentzabbix-agent 10050/udp # Zabbix Agentzabbix-trapper 10051/tcp # Zabbix Trapperzabbix-trapper 10051/udp # Zabbix Trapperit’s no big deal not to have it mentionned, but since your tuto is a sweet step-by-step ^^

    Reply to this comment
  4.    

    I guess you meant that the following entries should be added in /etc/services,
    and I would agree that it would be appropriate as well.
    Thanks. I just added it.

    zabbix-agent 10050/tcp # Zabbix Agent
    zabbix-agent 10050/udp # Zabbix Agent
    zabbix-trapper 10051/tcp # Zabbix Trapper
    zabbix-trapper 10051/udp # Zabbix Trapper

    Reply to this comment
  5.    

    Yup I meant that, I don’t know why the text formatting when just fubar.Thanks 🙂

    Reply to this comment
  6.    

    Perfect tutorial. Just installed on Debian Squeeze x64 and working without any problem

    Reply to this comment
  7.    

    man tanks for this post, works 100% .

    Reply to this comment
  8.    

    I just adapted it to work with Zabbix 2.0.4 but didn’t test the whole procedure from start to end. So if you find errors, I would appreciate you let me know so I can correct them.

    Reply to this comment
  9.    

    you can also use (for debian): configure –enable-server –with-postgresql –with-net-snmp –with-libcurl –with-openipmi –with-jabber –with-ssh2 –enable-agent –prefix=/usr –mandir=\${prefix}/share/man –infodir=\${prefix}/share/info –sysconfdir=/etc/zabbix

    it will install zabbix to the debian-way..

    Reply to this comment

Leave a Reply to Julio Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: