Nitish Kumar's Blog

Layman's take on technology | Doesn't need to have a super brain | Just do your bit

Archive for January 3rd, 2010

Making Zabbix Monitoring Server from Scratch: The Dummies Manual

with 43 comments

Update: Wrote this post long back.. just was meant to show that how easy it could be…many things needs to be Add to Google Buzzupdated in reference to new features and UI.. will update soon. Recently I received a book over Zabbix from Packt Publicing. Amazing book and probably the only available for the same. Worth buying….

“ How we system administrators work in case of any trouble? If something goes down or anything wrong would have happened and we get asked about how it happened? We just run into logs or try to guess what would have been happened, was it high CPU, low disk space or tremendous network traffic? Sometimes we get our answers, sometime not and we keep on saying ourselves that we can’t be everywhere to monitor each and everything all the time. But it’s the time to update yourself and get optimized. I went through a few of monitoring solutions and with their pros and cons, finally I got settled with the Open Source Solution developed by Zabbix SIA. ”

 

What is Zabbix? Before the configuration and installation part, I am starting with a little history.zabbix1_thumb Zabbix is a network management system application created by Alexei Vladishev in 1998 (public release in 2001) to monitor and track the status of various network services, servers, and other network hardware. Zabbix uses MySQL, PostgreSQL, SQLite or Oracle to store data. Its backend is written in C and the web frontend is written in PHP and javascript.

Zabbix offers several monitoring options. Simple checks can verify the availability and responsiveness of standard services such as SMTP or HTTP without installing any software on the monitored host. A Zabbix agent can also be installed on UNIX and Windows hosts to monitor statistics such as CPU load, network utilization, disk space, etc. As an alternative to installing an agent on hosts, Zabbix includes support for monitoring via SNMP, TCP and ICMP checks, IPMI and custom parameters. Zabbix supports a variety of real-time notification mechanisms, including XMPP.



Installation and Configuration to monitor Windows\ Linux Servers:

Although I tried and found it extremely efficient , but even then I didn’t went along with the wonderful easy install procedure made by Brendon Baumgartner, not due to some fault in that one, but due to inherent problems with I guess not stable yet latest version of zabbix. But I sure be waiting for BB to write other magic scripts in the same way to make things one Enter only.

Here comes the way, I followed to install zabbix in manual way over the servers.

Step by Step Implementations with details:

Base machine: As for most of Linux Development I choose, even here I am choosing CentOS as the base system to build the solution upon. One should go for at least CentOS 5.x as there are a few options not available with older CentOS 4.x. As per recommendation for CentOS, machine should have at least 512 MB RAM and decent processor, LAN card etc. and although not kind of requirement but the machine should has ample space in it to store logs for as many days.

As usually I do, installation was customized with 1GB swap, 200 MB of boot partition, all PHP/ MySQL related packages checked, all libraries checked, SendMail package checked. In next, as the installation will pull updates, packages from internet directly, so Ethernet configurations should be ready and internet should be working fine over the same machine. Also note that it would be around 27-28 mb download size in total while installation.

Pre-requisites for the installation:

First of all, we need to finish installation/ update of all required packages in reference with zabbix installation.

yum install httpd php mysql mysql-server mysql-devel php-gd php-mysql php-bcmath gcc net-snmp net-snmp-libs net-snmp-utils net-snmp-devel curl-devel

Once finished with this, one need to check whether the crucial components are configured to start with the system and are working well.

# service httpd start
# chkconfig –add httpd
# chkconfig httpd on
# service mysqld start
# chkconfig –add mysqld
# chkconfig mysqld on

Possible issues and resolutions first:

Need to check whether things are working fine.

# mysql –u root

This should leave one to MySQL prompt, if not then need to check. In next, need to check whether httpd is working fine (Apache is properly installed and configured). Type the IP Address of the target Zabbix Installation Server in browser from some other computer, if you are able to see Apache page, then its fine otherwise you will be needed to check things like SELINUX.

How to check selinux status?

Execute the following command:

# sestatus

If its showing it enabled, then could disable it by

# setenforce 0

To permanently disabled the same, we need to do some editing in configuration file, otherwise it will be back with the next boot

# vi /etc/selinux/config

The file must look like (after setting SELINUX=disabled)

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted – Only targeted network daemons are protected.
# strict – Full SELinux protection.
SELINUXTYPE=targeted

Check if the browser started opening apache page after this, if yes, then we are done, otherwise should look down in /var/log/httpd/error.log for other possible reasons.

Installation and configuration steps:

Here I am assuming that you are using CentOS 5.x as base, otherwise the configurations might be altered.

# cd /usr/src
#wget
http://internap.dl.sourceforge.net/sourceforge/zabbix/zabbix-1.4.5.tar.gz
# tar zxf zabbix-1.4.5.tar.gz
# cd zabbix-1.4.5
# mysql -u root
# mysql> create database zabbix;
# mysql> quit
# cat create/schema/mysql.sql | mysql -u root zabbix
# cat create/data/data.sql | mysql -u root zabbix
# cat create/data/images_mysql.sql | mysql -u root zabbix
# ./configure –enable-server –enable-agent –with-mysql –with-net-snmp –with-libcurl
# make install
# mkdir /etc/zabbix
# cp misc/conf/* /etc/zabbix
# groupadd zabbix
# useradd -g zabbix zabbix
# chown zabbix:zabbix /usr/local/sbin/zabbix*
# cp misc/init.d/redhat/8.0/zabbix* /etc/init.d
# vi /etc/init.d/zabbix_agentd

change BASEDIR=/opt/zabbix to BASEDIR=/usr/local/sbin

change FULLPATH=$BASEDIR/bin/$BINARY_NAME to FULLPATH=$BASEDIR/$BINARY_NAME

# vi /etc/init.d/zabbix_server

Make the same changes as above.

# chkconfig –add zabbix_agentd
# chkconfig –add zabbix_server
# chkconfig –level 3 zabbix_server on
# chkconfig –level 3 zabbix_agentd on

Now, installing the web application….

# mkdir /var/www/html/zabbix
# cp -R frontends/php/* /var/www/html/zabbix
# chown apache:apache /var/www/html/zabbix/conf
# vi /etc/php.ini

Find resource limits section and change max_execution_time to 300

;;;;;;;;;;;;;;;;;;; ; Resource Limits ; ;;;;;;;;;;;;;;;;;;;

max_execution_time = 300 ; Maximum execution time of each script, in seconds

Also make changes for date.timezone entry, it should be commented, uncomment it and set it accordingly like in case of India ..

date.timezone=ASIA/CALCUTTA

At the end, start zabbix services

# service zabbix_server start
# service zabbix_agentd start

Add zabbix ports to be listened to the configuration of services.

# vi /etc/services

And put the following two lines at the very end of the file.

zabbix_agent 10050/tcp # Zabbix ports
zabbix_trap 10051/tcp

Zabbix Server console installation is ready to and web installation is ready to go from here.

After finishing all the above steps, now go to url http://IP_ADDRESS/zabbix (Here IP_ADDRESS is what you have given to the server Ethernet port)

It should ask for installation steps, if you have followed my steps exactly, then it must go like next, next only. After finishing all the steps, you will get a login prompt, user name will be admin here and password is blank. After login, go to profile link and change the password to whatever suits to you. Logout and login again. Click monitoring and then go to screens in second row. You should get five screens on the same page for the zabbix server itself. One screen must be having map only. Check that rest all showing you graphs or not. If yes, then server side work is done and you are ready to move towards adding clients.

Zabbix Agent Installation over Linux Clients:

First part is to download the appropriate zabbix agent package from the official page. I assume, your clients (Servers to monitor) are updated and have kernel at least 2.6.x (If not then choose the suitable package).

# yum install net-snmp net-snmp-libs net-snmp-utils net-snmp-devel curl-devel (Optional)
# groupadd zabbix
# useradd -g zabbix zabbix
# cd /usr/src
#wget
http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/1.8/zabbix-1.8.tar.gz/download
# tar zxvf zabbix-1.8.tar.gz
# cd zabbix-1.8
# chmod 7555 *
# ./configure -enable-agent -with-mysql -with-net-snmp -with-libcurl
# make install
# chown zabbix:zabbix /usr/local/sbin/zabbix*
# mkdir /etc/zabbix
# cp misc/conf/* /etc/zabbix
# cp misc/init.d/redhat/8.0/* /etc/init.d
# chmod +x /etc/init.d/zabbix_*

Now, Change the binary location to /usr/local/sbin

# vi /etc/init.d/zabbix_agentd

In next, make the zabbix agent point to your Zabbix Server by putting Server’s IP Address in configuration file of agent

# vi /etc/zabbix/zabbix_agentd.conf

And as final step on client side, set up the services

# chkconfig –add zabbix_agentd
# chkconfig –level 3 zabbix_agentd on
# service zabbix_agentd start

Getting the graphs from data coming from agents:

You will see that Zabbix Server itself added in the WebUI. In place of creating a new monitoring scenario, first it’s easier to copy the same entries to the newly added Linux Servers.

Go to Hosts, create a new host with the name of your agent (whatever name you choose), select group as Linux Server, then put the right IP Address and set the tab below to it on IP Address and save.

After this, go to Items, from combo box at right top, select zabbix server, it will show up items already configured for zabbix server, you need to select all the items and press copy selected items to button at the bottom and then when it will show the list of all templates and hosts configured, choose the one, you just created.

From here, you have setup items to fetch data from agent, now how to use it. Go to graphs, from right top select zabbix server and copy all the graphs to newly created server. Graphs are ready from here.

Finally, make a screen to monitor. Make a screen of 2×2 and give it the name as per your choice. Once screen created, click edit. Then configure CPU Loads, CPU Utilization, Disk Space and Network Utilization graphs for the agent, you setup and you are ready to monitor your Linux Server.

Zabbix Agent Installation over Windows Clients:

I find Windows Installation easier in first part and little bit complicated in second part. First need to download the windows agent from here

http://www.zabbix.com/downloads/1.8/zabbix_agents_1.8.win.zip

Then install it and it will ask for server IP Address, give zabbix server’s IP Address. Now, go to WebUI of Zabbix Server, Create host/items/graphs/screens in similar ways and you are ready to go.

There are many features that are there in Linux Agent but nowhere in Windows one. One workaround is to use data fetched from Windows Performance Monitor (permon.exe).

For example: Network Utilization

Go to cmd, type typeperf –qx |find “Network” >c:\network.txt

Now, check the network.txt file created in C: drive, it would be containing the exact network resource/ variable name for bytes sent and bytes received.

Now, how to call it?

Go to C:\program files\zabbix agent\zabbix_agentd.conf

Add something like following lines at the end…

PerfCounter= Server1NetIn,"\Network Interface(Intel Pro Server Adapter)\Bytes Received/sec",60
PerfCounter= Server1NetOut,"\Network Interface(Intel Pro Server Adapter)\Bytes Sent/sec",60

Note that the value placed in inverted commas is exactly the same, which you must have obtained from that network.txt file. Restart the Zabbix Service from services.msc. Now, go to Zabbix Server WebUI, create an item in target Windows Server area with any name for Network and put Server1NetIn or Server1NetOut as key. Save item and you are ready to use it in your graphs :)

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Written by Nitish Kumar

January 3, 2010 at 12:07 pm

Follow

Get every new post delivered to your Inbox.

Join 2,787 other followers

%d bloggers like this: