Sunday, June 13, 2010

Monitoring with Nagios

If planning on monitoring your servers, Nagios is the guy.

Official documentation:
http://www.nagios.org/documentation
http://nagios.sourceforge.net/docs/3_0/toc.html

For Fedora configuration and SElinux issues refer to:
http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html

Install the necessary packages:
#---
yum -y install \
httpd \
php \
nagios \
nagios-plugins-all
#---


Main configuration and relevant files:
/etc/httpd/conf.d/nagios.conf -- (refer further on by the alias http-nagios)
/var/log/httpd/error_log -- error_log (alias)
/var/log/httpd/access_log -- access_log (alias)
/etc/nagios/passwd -- pass_nagios (alias)
/etc/nagios/nagios.cfg -- cfg_nagios (alias)
/etc/nagios/cgi.cfg -- cgi_nagios (alias)


The default user is "nagios" (specified in http-nagios) and you need to set its password before trying to access your fresh Nagios site
#---
htpasswd -c /etc/nagios/passwd nagios
#---


Add further users, such as the nagiosadmin, with:
#---
htpasswd /etc/nagios/passwd nagiosadmin
#---

Check it:
#---
cat /etc/nagios/passwd
#---


Setup Nagios to accept access from the nagios user: editing the cgi_nagios file and change it to have the following settings:

...
authorized_for_system_information=nagiosadmin,nagios
...
authorized_for_all_services=nagiosadmin,nagios
authorized_for_all_hosts=nagiosadmin,nagios
...
authorized_for_read_only=nagios
...


Note: every time you change your cgi_nagios file you need to restart the nagios service:
#---
service nagios restart
#---


Start the services:
#---
service httpd start
service nagios start
#---


Set services to run automatically:
#---
chkconfig --level 345 httpd on
chkconfig --level 345 nagios on
#---


Try to access the home-page:
http://127.0.0.1/nagios/
or
http://127.0.0.1/nagios/index.php

Note: This is VERY important to notice that it is NOT localhost but 127.0.0.1. You can change it on http-nagios file.
Troubleshooting: If have any problem look at error_log file and check if the user is actually on the pass_nagios file.

No comments: