Friday, August 3, 2012

Setup nagios

Nagios Server

add rpmforge into the server repo

# yum install nagios nagios-nrpe nagios-plugins nagios-plugins-nrpe perl-Nagios-Plugin
# chkconfig nagios on
# chkconfig nrpe on

Edit the /etc/httpd/conf.d/nagios.conf to remove the SSL and user authentication
# vim /etc/httpd/conf.d/nagios.conf


  1  ScriptAlias /nagios/cgi-bin "/usr/lib64/nagios/cgi"
  2
  3  <Directory "/usr/lib64/nagios/cgi">
  4  #  SSLRequireSSL
  5     Options ExecCGI
  6     AllowOverride None
  7     Order allow,deny
  8     Allow from all
  9  #   AuthName "Nagios Access"
 10  #   AuthType Basic
 11  #   AuthUserFile /etc/nagios/htpasswd.users
 12  #   Require valid-user
 13  </Directory>
 14
 15  Alias /nagios "/usr/share/nagios"
 16
 17  <Directory "/usr/share/nagios">
 18  #  SSLRequireSSL
 19     Options None
 20     AllowOverride None
 21     Order allow,deny
 22     Allow from all
 23  #   AuthName "Nagios Access"
 24  #   AuthType Basic
 25  #   AuthUserFile /etc/nagios/htpasswd.users
 26  #   Require valid-user
 27  </Directory>
-----------------------------------------------------------------------------------

Edit /etc/nagios/cgi.cfg
# vim /etc/nagios/cgi.cfg


 use_authentication=0
 use_ssl_authentication=0
----------------------------------------------------------------------------------
# vim  /etc/nagios/objects/server.cfg



define hostgroup{
        hostgroup_name  linux-server
        alias           Linux Servers
        members         localhost,my-dns2
        }


define host{
        use                     linux-server
        host_name               my-dns2
        alias                   my-dns2
        address                 my-dns2.offgamers.lan
        }

define service{
        use                     local-service
        host_name               my-dns2
        service_description     Swap
        check_command           check_nrpe!check_swap
        }




# vim  /etc/nagios/nagios.cfg

add the location of the hosts file in the object folder


Format: cfg_file=<file_name>
Example: cfg_file=/usr/local/nagios/etc/hosts.cfg
                cfg_file=/usr/local/nagios/etc/services.cfg
                cfg_file=/usr/local/nagios/etc/commands.cfg





Nagios Client


# yum install nagios-nrpe nagios-plugins nagios-plugins-nrpe perl-Nagios-Plugin
# chkconfig nrpe on

# vim /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1,172.30.10.218

at the bottom, edit the check command to suit your environment
----------------------------------------------------------------------------------





If you start Nagios server having error
use
# nagios -v /etc/nagios/nagios.cfg 
to check whats wront




Nagios Option available

http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html

smokeping 2.6.8 for Centos 6.3

add rpmforge into your linux repo

yum install:

  • mod_fcgid
  • httpd
  • httpd-devel
  • rrdtool
  • perl-CGI-SpedtCGI
  • fping
  • perl-RRD-Simple
  • perl
# yum install mod_fcgid httpd httpd-devel rrdtool perl-CGI-SpeedCGI fping perl-RRD-Simple perl
# yum groupinstall "Development tools"

download the smokeping package from
http://oss.oetiker.ch/smokeping/pub/

# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz
# tar -zxvf smokeping-2.6.8.tar.gz
# mv smokeping-2.6.8  /opt/smokeping
# cd smokeping-2.6.8

then manual install perl package manually

#perl -MCPAN -e shell

> install FCGI
> install CGI::Fast
> install Config::Grammar
> install Digest::HMAC_MD5
> install Net::Telnet
> install Net::OpenSSH
> install Net::SNMP
> install Net::LDAP
> install Net::DNS
> install IO::Pty
> install LWP


other from manually install, you can run the script locate at smokeping /opt/smokeping/setup
# cd  /opt/smokeping/setup
# ./build-perl-modules.sh

after done, run to configure and make install
# cd /opt/smokeping
# ./configure --prefix=/opt/smokeping
# make install


now we go for preparing for the configuration file
# cd /opt/smokeping/etc
# for foo in *.dist; do cp $foo `basename $foo .dist`; done

#vim /etc/httpd/conf/httpd.conf

change:
DirectoryIndex index.html index.html.var
to:
DirectoryIndex index.html index.html.var smokeping.fcgi

then enable this
AddHandler cgi-script .cgi

-------------------------------------------------------------------------------------------
# vim /etc/httpd/conf.d/smokeping.conf

<Directory "/var/www/html/smokeping">
    Options +ExecCGI
</Directory>
-------------------------------------------------------------------------------------------

# mkdir /opt/smokeping/img
# chown -R apache:apache /opt/smokeping/img
# ln -s /opt/smokeping/htdocs /var/www/html/smokeping
# ln -s /opt/smokeping/img /var/www/html/smokeping

# mkdir /opt/smokeping/data

# mkdir /opt/smokeping/var

# chmod 600 /opt/smokeping/etc/smokeping_secrets
# chown -R apache:apache /var/www/html/smokeping

restart the httpd
# /etc/init.d/httpd restart

edit the smokeping config to your need
# vim /opt/smokeping/etc/config

start the smokeping services
# ./bin/smokeping --config=/opt/smokeping/etc/config --logfile=smoke.log


Reference and help thanks to Tony from http://ai.net.nz