Nagios on RHEL 6

Installing EPEL Repository
Download epel release repo from below URL:
[root@]$ wget -c http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/i386/epel-release-6-7.noarch.rpm
If in case you are using RHEL5 you can download this epel-release from below URL:
http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm



Installing pre-requisites packages
Install the pre-requisites software’s like:
· Php
· Gcc, Gcc++
· Httpd
· Gd
· Perl
[root@]$yum install php gcc* httpd gd perl –y


Installing Nagios and some additional packages
Install major packages like:
· Nagios
· Nagios-common
· Nagios-plugins
· And some basic plugins like nagios-plugins-ping, nagios plugins-http, nagios-plugins-disk etc.
[root@]$yum install nagios nagios-common nagios-plugins nagios-plugins-http nagios-plugins-disk nagios-plugins-ping -y


Major configuration files
To configure Nagios, you first need to find their configuration file. To locate configuration files provided by the Nagios package, you can fire command as:
[root@]# rpm -qc nagios
/etc/httpd/conf.d/nagios.conf
/etc/logrotate.d/nagios
/etc/nagios/cgi.cfg
/etc/nagios/commands.cfg
/etc/nagios/localhost.cfg
/etc/nagios/nagios.cfg
/etc/nagios/private/resource.cfg

==> The main configuration files
  • /etc/nagios/nagios.cfg 
==> Object definition files:
  • /etc/nagios/commands.cfg 
  • /etc/nagios/localhost.cfg 
==> Resource configuration file:
  • /etc/nagios/private/resource.cfg 
==> Contacts configuration file: 
  • /etc/nagios/objects/contacts.cfg 
==> CGI configuration file:
  • /etc/nagios/cgi.cfg 
==> Apache configuration file:
  • /etc/httpd/conf.d/nagios.conf 
    • This file contains the directive for the URLs like http://NAGIOS _HOST/nagios/ and http://NAGIOS_HOST/nagios/cgi-bin/ 

What does these files contain
  • Main configuration file: /etc/nagios/nagios.cfg 
    • This file contains the location of files which are mandatory for Nagios like log files, object configuration files etc. The information of some of the basic parameters are given below: 
    • LOG FILE: This is the main log file where service and hosts events are logged for historical purposes. 
§ => log_file=/var/log/nagios/nagios.log 
    • OBJECT CONFIG FILE: There are various object config files like commands.cfg, contacts.cfg, localhost.cfg and many more you can also add in this as per your requirements. An example of one of the config file is as: 
§ => cfg_file=/etc/nagios/objects/commangs.cfg
    • If you have a number of servers/printers in your organization then you can create a directory and include that as: 
§ => cfg_dir=/etc/nagios/servers
    • RESOURCE FILE: This is a optional resource file which contains users macro definitions which is useful for storing sensitive information like username and passwords. 
§ => resource_file=/etc/nagios/private/resource.cfg
    • STATUS FILE: In this file the current status of all monitored services and hosts are stored. 
§ => status_file=/var/log/nagios/status.dat
    • STATUS UPDATE INTERVAL: The frequency for updating the status data. 
§ =>status_update_interval=10
    • NAGIOS USER: 
§ => nagios_user=nagios
    • Nagios Group: 
§ => nagios_group=nagios
    • And there are many more as your requirements a sample of nagios.fg is attached.
Sample of nagios.cfg


Main object definition files:
  • /etc/nagios/objects/commands.cfg 
  • /etc/nagios/objects/localhost.cfg 
  • /etc/nagios/objects/remotehosts.cfg 
    • If in case if you want to add any remote hosts for monitoring on nagios but do remember you need to add this file’s parameter in the major nagios.cfg file.
  • All the necessary object definition files are attached; if you want then you can have a look on those remotehosts.cfg is the file which was added by me this contains a remote host called “server.redhat.com” and the services like ping, http, disk, partition which we need to monitor on our nagios server.
Sample of commands.cfg
Sample of localhost.cfg
Sample of remotehosts.cfg


Contacts definition file:
This file contains the contact information of nagios admin, you can add more as per your requirements. The default contacts.cfg file is attached:
Sample of contacts.cfg


Mapping nagios with httpd:
/etc/httpd/conf.d/nagios.conf
Sample of nagios.conf

Don’t forget to check whether this file has been included in httpd.conf, if not then include that in httpd.conf


Checking whether the config file which you added or edited are correct or not ?
[root@]# /usr/sbin/nagios –v /etc/nagios/nagios.cfg

If all goes well it will show you:

Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check.


If not then it will show you some error or warning which you need to troubleshoot which will be listed on the terminal only.


Now add a Nagios User:
[root@]# htpasswd -bc /etc/nagios/passwd nagiosadmin nagios
    • Here nagiosadmin is your username and nagios is the password. 
Now just restart your services:
[root@]# service httpd restart
[root@]# service nagios restart
[root@]# chkconfig nagios on
[root@]# chkconfig httpd on

Now try to open Nagios home page on your firefox or any-other browser:
[root@]# firefox localhost/nagios & 
    • Here localhost is your server on which nagios is hosted. 

# Some of the screen-shots of nagios are as follows:
Login Screen:
Home Page:
Service Status:




NOTE: 
.cfg or .conf files are not recognized by google docs so for viewing the content of those file first download those then view in a text editor.

Comments

Post a Comment

Popular posts from this blog

Installing Tomcat8 on RHEL6

Manage existing resources via Helm

Configuration and setting-up of AIDE on RHEL6