How to Install Nagios

From DISI
Revision as of 21:45, 30 June 2016 by Benrwong (talk | contribs) (Created page based on "HOW TO INSTALL NAGIOS" from Lab Manual)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Installation

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 127.0.0.1 169.230.26.0/24 169.230.90.0/24 10.20.0.0/16
htpasswd /etc/nagios/passwd nagiosadmin service nagios start service httpd start chkconfig nagios on chkconfig httpd on

CONFIGURE NAGIOS/ADDING CLIENTS:

http://nagios.sourceforge.net/docs/3_0/macrolist.html
http://nagios.sourceforge.net/docs/3_0/monitoring-publicservices.html
http://wiki.centos.org/HowTos/Nagios 

Plugins list: https://nagios-plugins.org/doc/man/index.html To see how a specific plugin works (say for ssh):

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

The different timeperiods are defined here:

/etc/nagios/objects/timeperiods.cfg

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

/etc/nagios/objects/templates.cfg 

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=169.230.26.197 (the ip of the nagios server)
service nrpe start
chkconfig nrpe on 
              • NOTE FOR CENTOS 5*****************

For i386:

rpm -Uvh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS//rpmforge-release-0.5.3-1.el5.rf.i386.rpm

For x86_64:

rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

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
       host_name                       delta.cluster.ucsf.bkslab.org
       alias                           delta
       address                         10.20.1.4
       max_check_attempts              5
       check_period                    24x7
       notification_interval           30
       notification_period             24x7
} 
define service { use generic-service host_name delta.cluster.ucsf.bkslab.org service_description PING check_command check_ping!100.0,20%!500.0,60% } define service { use generic-service host_name delta.cluster.ucsf.bkslab.org service_description SSH check_command check_ssh notifications_enabled 1 } define service { use generic-service host_name delta.cluster.ucsf.bkslab.org 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


References:

http://www.unixmen.com/install-and-configure-nagios-in-centos-6-4-rhel-6-4/ https://www.digitalocean.com/community/tutorials/how-to-install-nagios-on-centos-6