Wednesday, September 14, 2011

Monitor Your Network with Zabbix Monitoring Solution : Installation HOWTO


A Web Host has to actively monitor all the services running on each of its Internet Servers. Customers assume that the services advertised by the host are available 24/7, and hence Internet servers monitoring takes a high priority in the Web Hosting business world. A Web Host can be sure that all promises are being kept through an effective server monitoring system. A software installed on one server which can remotely monitor your Internet servers becomes the best solution. There are Commercial and Free options.
Zabbix, which has both free and commercial support, is a high-class open source distributed monitoring solution. Zabbix is a network management system application used to monitor and track the status of various network services, the server health and integrity, and other network hardware. It also allows support to configure e-mail alerts for an event which will help them to quickly react to any server problem. Zabbix has a very good graphic visualization and it plays an important role in monitoring a small batch or a multitude of servers.
In order to store data, Zabbix uses MySQL, PostgreSQL, SQLite or Oracle database engine. This article deals with the Installation and access mechanism of Zabbix.

Table of Contents

  1. Installation of Zabbix
  2. Zabbix Monitoring System Access
  3. Conclusion

1. Installation of Zabbix

As a pre-requisite, make sure that you have the following packages installed on your machine.
http, mysql, gcc, mysql-server, mysql-devel, net-snmp, net-snmp-utils, net-snmp-devel, net-snmp-libs, curl-devel, mak, ntp, php - with bcmath, gd and mysql support
You can use the Yum installer to install the above packages.
yum -y install package-name
Startup the time server for syncing the time between devices:
/etc/init.d/ntpd start
Download and Install fPing -
wget http://dag.wieers.com/rpm/packages/fping/fping-2.4-1.b2.2.el5.rf.i386.rpm
rpm -Uvh fping-2.4-1.b2.2.el5.rf.i386.rpm
chmod 7555 /usr/sbin/fping
Create Zabbix user -
useradd zabbix
Download Zabbix and Untar it -
wget http://jaist.dl.sourceforge.net/sourceforge/zabbix/zabbix-1.4.4.tar.gz
tar -xzvf zabbix-1.4.4.tar.gz
Grant zabbix database access to the corresponding user -
mysql -u root -p
mysql> CREATE DATABASE zabbix;
mysql> GRANT DROP,INDEX,CREATE,SELECT,INSERT,UPDATE,ALTER,DELETE ON zabbix.*
TO zabbixmysqluser@localhost IDENTIFIED BY ‘zabbixmysqlpass’;
Create the DB Schema -
cd zabbix-1.4.4
cat create/schema/mysql.sql | mysql -u zabbixmysqluser -pzabbixmysqlpass zabbix
cat create/data/data.sql | mysql -u zabbixmysqluser -pzabbixmysqlpass zabbix
cat create/data/images_mysql.sql | mysql -u zabbixmysqluser -pzabbixmysqlpass zabbix
Zabbix has a very good graphic visualization and it plays an important role in monitoring a small batch or a multitude of servers.
Configuring Zabbix server -
./configure –enable-server –prefix=/usr/local/zabbix –with-mysql –with-net-snmp –with-libcurl
make install
make clean
Compile the Zabbix agent -
./configure –enable-agent –prefix=/usr/local/zabbix –enable-static
make install
Add Zabbix server and agent ports to /etc/services file - >
echo “zabbix_agent 10050/tcp” >> /etc/services
echo “zabbix_trap 10051/tcp” >> /etc/services
Copy sample .conf files to /etc/zabbix/ for server and agentd -
cd /etc/
mkdir zabbix
cp misc/conf/zabbix_agentd.conf /etc/zabbix
cp misc/conf/zabbix_server.conf /etc/zabbix
Modify the .conf files as per requirements. In/etc/zabbix/zabbix_server.conf file, change the following -
DBUser=zabbixmysqluser
BPassword=zabbixmysqlpassword
DBSocket=/var/lib/mysql/mysql.sock
FpingLocation=/usr/sbin/fping
Changes in /etc/zabbix/zabbix_agentd.conf file -
Server=127.0.0.1,your.zabbix.server.IP
Hostname=EnterTheHostName
cp misc/init.d/redhat/zabbix_agentd_ctl /etc/init.d/zabbix_agentd
cp misc/init.d/redhat/zabbix_server_ctl /etc/init.d/zabbix_server
Changes in /etc/init.d/zabbix_agentd and /etc/init.d/zabbix_serverfiles -
BASEDIR=/usr/local/zabbix
In the file /etc/init.d/zabbix_agentd, add the following on the top just after #!/bin/sh -
# chkconfig: 345 95 95
# description: Zabbix Agentd
In the file /etc/init.d/zabbix_server, add the following on the top just after #!/bin/sh -
# chkconfig: 345 95 95
# description: Zabbix Server
Configuring auto start and stop of services for different run levels -
chkconfig –level 345 zabbix_server on
chkconfig –level 345 zabbix_agentd on
chkconfig –level 345 httpd on
chkconfig –level 345 mysqld on
chkconfig –evel 0123456 iptables off
At the end of this step, please make sure that connections to ports 10050 and 10051 are allowed in the firewall settings. Re-check the firewall rules.
Copy the Zabbix front-end file(s) to the server’s DocumentRoot -
cp -r frontends/php /var/www/html/zabbix
Modify the /etc/php.ini file with the following -
max_execution_time = 300
date.timezone = Asia/Calcutta
Note: Remember to specify your time zone in the above setting. You can obtain the time zone name fromhttp://us2.php.net/manual/en/timezones.america.php
Zabbix has an easy mechanism to add the host or service that needs to be monitored, when compared to other software.
Start Apache server for the changes to take effect -
 /etc/init.d/httpd start 
How to execute the LICENSE -
chmod 777 /var/www/html/zabbix/conf
Access http://your-hostname/zabbix and simply follow the instructions.
While you run the steps, you will have to setup the/var/www/html/zabbix/php/conf/zabbix.conf.php file. A sample file would look like how it is shown below -
global $DB_TYPE, $DB_SERVER, $DB_PORT, $DB_DATABASE, $DB_USER, $DB_PASSWORD,
$IMAGE_FORMAT_DEFAULT;

$DB_TYPE = “MYSQL”;
$DB_SERVER = “localhost”;
$DB_PORT = “0″;
$DB_DATABASE = “zabbix”;
$DB_USER = “zabbixmysqluser”;
$DB_PASSWORD = “zabbixmysqlpass”;

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
Once the installation is complete, execute the following steps -
chmod 755 /var/www/html/zabbix/conf
mv /var/www/html/zabbix/setup.php /var/www/html/zabbix/setup.php.bk
/etc/init.d/zabbix_agentd start
/etc/init.d/zabbix_server start

2. Zabbix Monitoring System Access

http://your-hostname/zabbix/
Login into the Admin area using “admin” as user name. It does not require password at this point, and you can set the login password after you are inside the portal.
If http://your-hostname/zabbix/ does not show anything, it is possible that the php-pear module isn’t installed. In that case, you should consider installingphp-pear using the Yum installer. 
yum -y install php-pear
You might also want to verify the error logs to spot the exact point of error.
Refer Zabbix tutorial to get more information - 
http://www.zabbix.com/manual/
You can also use tips related to zabbix from the forum thread located at - 
http://www.zabbix.com/forum/forumdisplay.php?f=11
Note: Remember to change zabbixmysqlpass and zabbixmysqluser with preferred values.

3. Conclusion

Zabbix is a software which you can learn quickly and when all is done, it is a complete tool. It combines several functions that are left out of other monitoring software and has a good data collection system. Zabbix has an easy mechanism to add the host or service that needs to be monitored, when compared to other software. It also allows you to build your own maps of different network segments while monitoring many hosts. It has also been reported that Zabbix Windows agent is very easy to install.

Reference: