How to Install Nagios

Jump to navigation Jump to search


yum install php httpd mysql gd gd-devel gcc glibc glibc-common nagios nagios-plugins-all nagios-plugins-nrpe nrpe
service mysqld start
change the root password    #Just in case
service mysqld stop
edit the firewall to allow port 80 from everywhere 
vim /etc/nagios/objects/contacts.cfg => Change the email to your email
vim /etc/httpd/conf.d/nagios.conf
Comment out the lines “Order allow,deny” and “Allow from all” and add these lines: Order deny,allow Deny from all Allow from
htpasswd /etc/nagios/passwd nagiosadmin service nagios start service httpd start chkconfig nagios on chkconfig httpd on


Plugins list: To see how a specific plugin works (say for ssh):

/usr/lib64/nagios/plugins/check_ssh --help 

The different timeperiods are defined here:


Dummy templates for setting up dummy client.cfg files are here:


To add a client:

ssh to the client and do the following:
yum install nrpe nagios-plugins-all openssl
vim /etc/nagios/nrpe.cfg  => Changed: 
 allowed_hosts= (the ip of the nagios server)
service nrpe start
chkconfig nrpe on 
              • NOTE FOR CENTOS 5*****************

For i386:

rpm -Uvh

For x86_64:

rpm -Uhv

Back on nagios server:

vim /etc/nagios/nagios.cfg
Uncomment this line   =>      cfg_dir=/etc/nagios/servers
mkdir /etc/nagios/servers
vim /etc/nagios/servers/client_hostname.cfg

I created one that looks like this for delta.cfg: ++++++++++++++++++++++++++++++++++++++++++++

define host{
       use                             linux-server
       alias                           delta
       max_check_attempts              5
       check_period                    24x7
       notification_interval           30
       notification_period             24x7
define service { use generic-service host_name service_description PING check_command check_ping!100.0,20%!500.0,60% } define service { use generic-service host_name service_description SSH check_command check_ssh notifications_enabled 1 } define service { use generic-service host_name service_description Current Load check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 }


service nagios restart

That’s pretty much it! Nagios Hostgroups:

On the nagios server: vim /etc/nagios/nagios.cfg Add the line => cfg_file=/etc/nagios/objects/hostgroups.cfg vim /etc/nagios/objects/hostgroups.cfg => define hostgroup{

       hostgroup_name  cluster_2


Then to add a server to this hostgroup: vim /etc/nagios/servers/delta.cfg Add this line within the “define host” curly brackets => hostgroups cluster_2

service nagios restart