Nagios 2.x

From INIwiki
(Redirected from Nagios)
Jump to: navigation, search

Digg this!

Contents

[edit] Install Nagios 2.10 from Source RedHat Based System

Check for latest verison here Download and untar Nagios

cd /usr/local/src/
wget http://easynews.dl.sourceforge.net/sourceforge/nagios/nagios-2.10.tar.gz
tar fxzv nagios-2.10.tar.gz

[edit] Configure the install

cd ./nagios*
./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios/ --with-nagios-user=nagios --with-nagios-group=nagcmd --with-command-group=nagcmd

Create User, groups, user directory and give permissions

useradd nagios
groupadd nagcmd
usermod -G nagcmd apache
usermod -G nagcmd nagios
mkdir /usr/local/nagios
chown nagios.nagcmd /usr/local/nagios

Make and install Nagios

make all
make install
make install-init

Install the libexec

cd /usr/local/src

Obtain from here (no direct download) http://sourceforge.net/projects/nagiosplug/  (nagiosplugin)
ie: wget http://superb-west.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.10.tar.gz
tar fxzv nagios-plugins-1.4.10.tar.gz
cd nagios-plugins*
./configure
make
make install

Create the apache redirect for nagios (Redhat Based systems; ie: CentOS)

vi /etc/httpd/conf.d/nagios.conf

-- paste in the following --

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
    AllowOverride AuthConfig
    Options ExecCGI
    Order allow,deny
    Allow from all
### ADDED
    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user
</Directory>

Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
    Options None
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
### ADDED
    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user
</Directory>

-- End Paste --

Save and Close VI with:
[esc]:wq

Reload Apache

service httpd restart
chkconfig httpd on  (if needed)

Setup your user accounts

mkdir /usr/local/nagios/etc/
chown nagios.nagcmd /usr/local/nagios/etc/

Admin User

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 

Additional Users

htpasswd /usr/local/nagios/etc/htpasswd.users <username>

[edit] Install Steps

Confiure Nagios:

cd /usr/local/nagios/etc/

Make the following files if they don't exist. - I will include mine below.

contacts.cfg -- user name is naguser

vi /usr/local/nagios/etc/contacts.cfg

define contact{
      contact_name                    naguser
      alias                           Nagios User
      service_notification_period     24x7
      host_notification_period        24x7
      service_notification_options    w,u,c,r
      host_notification_options       d,u,r
      service_notification_commands   notify-by-email
      host_notification_commands      host-notify-by-email
      email                           naguser@yourdomainhere.com
      }

contactgroups.cfg define contactgroup{
       contactgroup_name       admin
       alias                   Administrator
       members                 naguser
       }

hosts.cfg - repeat the section under MY HOSTS for all your hosts.

 vi /usr/local/nagios/etc/hosts.cfg

Generic Host Definition
define host{
       name                            generic-host    ; The name of this host template - referenced in other host definitions, used for template recursion/resolution
       notifications_enabled           1       ; Host notifications are enabled
       event_handler_enabled           1       ; Host event handler is enabled
       flap_detection_enabled          1       ; Flap detection is enabled
       process_perf_data               1       ; Process performance data
       retain_status_information       1       ; Retain status information across program restarts
       retain_nonstatus_information    1       ; Retain non-status information across program restarts
       register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
       check_command                   check-host-alive
       max_check_attempts              10
       notification_interval           60
       notification_period             24x7
       notification_options            d,u,r
       contact_groups                  admin
       }

### MY HOSTS ###
## For example I assume
## www = what nagios will call my web server
## www.inisec.com is the alias
## the internal IP address is 192.168.254.1
## The "linked" parent will be Firewall (left commented out because that host does not exist yet in nagios
##################################
define host{
       use                     generic-host            ; Name of host template to use
       host_name               WWW
       alias                   www.allni.com
       address                 192.168.254.1
#        parents                Firewall
       }

hostgroups.cfg - repeat for all you host groups

vi /usr/local/nagios/etc/hostgroups.cfg

define hostgroup{
       hostgroup_name  WebServers
       alias           Web Servers
       members         www
       }

services.cfg

vi /usr/local/nagios/etc/services.cfg

###Service Definitions for the XIMZ.COM Infrastructure
# Generic service definition template
define service{
       name                            generic-service ; The 'name' of this service template, referenced in other service definitions
       active_checks_enabled           1       ; Active service checks are enabled
       passive_checks_enabled          1       ; Passive service checks are enabled/accepted
       parallelize_check               1       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
       obsess_over_service             1       ; We should obsess over this service (if necessary)
       check_freshness                 0       ; Default is to NOT check service 'freshness'
       notifications_enabled           1       ; Service notifications are enabled
       event_handler_enabled           1       ; Service event handler is enabled
       flap_detection_enabled          1       ; Flap detection is enabled
       process_perf_data               1       ; Process performance data
       retain_status_information       1       ; Retain status information across program restarts
       retain_nonstatus_information    1       ; Retain non-status information across program restarts

       register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
       }
### MY Services Below  ###
#PING Service Definition
define service{
       use                             generic-service         ; Name of service template to use

       host_name                       *
       service_description             PING
       is_volatile                     0
       check_period                    24x7
       max_check_attempts              3
       normal_check_interval           5
       retry_check_interval            1
       contact_groups                  admin
       notification_interval           120
       notification_period             24x7
       notification_options            c,r
       check_command                   check_ping!500.0,20%!500.0,60%
       }

Check your config files with the following..

cd /usr/local/nagios/etc
../bin/nagios -v nagios.cfg

At the bottom you should see.

Checking misc settings...

Total Warnings: 0
Total Errors:   0

Just for sanity sake make sure all file are owned by nagios user and group

chown nagios.nagios /usr/local/nagios -R
mkdir /usr/local/nagios/var/rw
chown nagios.nagcmd /usr/local/nagios/var/rw -R

Build a cron task to ensure permissions

crontab -e

add the following

* 2 * * *     chown nagios.nagcmd /usr/local/nagios/var/rw -R

Start the nagios service

service nagios start

To have the service start on bootup

chkconfig nagios on

Best to have the web server start on boot up also

chkconfig httpd on

[edit] 3D Map Browser Plugin

Windows

http://www.parallelgraphics.com/products/cortona/

[edit] MySQL Logging

Additional Optional Steps

Log nagios to MySQL Download and install supporting files

cd /usr/local/src/
wget http://umn.dl.sourceforge.net/sourceforge/nagios/ndoutils-1.4b2.tar.gz
tar fxzv ndoutils-1.4b2.tar.gz
cd ndoutils-1.4b2
./configure
make

Relocate some of the files to the proper locations

cd src/
cp file2sock log2ndo ndo2db-2x ndomod-2x.o sockdebug /usr/local/nagios/libexec/

Configure MySQL

mysql –uroot
mysql> create database nagios;
mysql> GRANT ALL ON nagios.* TO 'nagios'@'localhost' IDENTIFIED BY 'nagios';
mysql> flush privileges;
mysql> GRANT ALL ON nagios.* TO 'nagios'@'localhost' IDENTIFIED BY 'nagios' with grant option;
mysql> flush privileges;
mysql> quit;

Additional Configuration Steps

cd ../
cd db/
mysql -unagios -pnagios nagios < mysql.sql
vi /usr/local/nagios/etc/nagios.cfg
   Edit as needed
vi /usr/local/nagios/etc/ndomod.cfg
   Edit as needed
vi /usr/local/nagios/etc/ndo2db.cfg
   Edit as needed
/usr/local/nagios/libexec/ndo2db-2x -c /usr/local/nagios/etc/ndo2db.cfg

Restart nagios service

service nagios restart

Verify install

tail -f /usr/local/nagios/var/nagios.log
   Verify all is working…


[edit] Move a nagios install

Follow the steps above then replace the following files/folders: (remember to backup all originals first)

mv /usr/local/nagios/etc /usr/local/nagios/etc.org
mv /usr/local/nagios/share /usr/local/nagios/share.org
Then rsync you existing files.

[edit] Install Nagios-Mysql for Debian

See here for now:

http://wiki.tryphon.org/How_to_install_Nagios_under_Debian

Install from apt

apt-get install nagios2

[edit] Attachments/Sample Files

Copy of the etc directory for Nagios (.rar)

Copy of the nagios.conf file (.conf)

Copy of the services.config file (.cfg)

Copy of the libexec directory for Nagios (.rar)

Digg this!

Personal tools