Showing posts with label Nagios. Show all posts
Showing posts with label Nagios. Show all posts

Sunday, 28 August 2016

NAGIOS SMS SERVICE INTEGRATION


NAGIOS SMS SERVICE INTEGRATION :

http://solutionsatexperts.com/sms-integration-with-nagios/

===============================================


###  commands.cfg



# Entry For User 1
#Host outage notification entries section

#  'notify-host-by-sms' Command Definition For Host
   define  command{
           command_name    notify-host-by-user1
           command_line    /usr/bin/printf "%b" "*****  Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState:  $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time:  $LONGDATETIME$\n" | wget "api.mVaayoo.com/mvaayooapi/MessageCompose?user=namdev.it@gmail.com:123456789&senderID=TEST SMS&receipientno=9860755532,8149477323&dcs=0&msgtxt=**  Type : $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ at:  $LONGDATETIME$ **"
     }


#Service outage notification entries section

#  'notify-service-by-sms' command definition for solutionsatexperts-and-appsupport
   define  command{
           command_name    notify-service-by-user1
           command_line    /usr/bin/printf "%b" "*****  Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService:  $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState:  $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional  Info:\n\n$SERVICEOUTPUT$\n" | wget  "api.mVaayoo.com/mvaayooapi/MessageCompose?user=namdev.it@gmail.com:123456789&senderID=TEST SMS&receipientno=9860755532,8149477323&dcs=0&msgtxt=**  Type : $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is  $SERVICESTATE$ at: $LONGDATETIME$ **"
   }

:wq




##  contacts.cfg

######## SMS Contact User Name Details #####

define contact{
        contact_name                    username             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           username            ; Full name of user
        email                           user@example.com  ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        host_notification_commands      notify-host-by-user1
        service_notification_commands   notify-service-by-user1
        }


:wq



=========================

#### SMS CONTACT GROUP ####


define contactgroup{
        contactgroup_name       SMS_GROUP
        alias                   Nagios Administrators
        members                 username1,username2
        }


#####  For Defind Server Contact Group In host.cfg

define host{
    use        linux-server    ; Inherit default values from a template
    host_name    serverhost    ; The name we're giving to this host
    alias        serverhost    ; A longer name associated with the host
        address        serverip    ; IP address of the host
        hostgroups        AWS-Windows
        notifications_enabled    1                                   ; For SMS Notification
        contact_groups          admins,SMS_GROUP
    }

define service{
    use            generic-service
    host_name        serverhost
    service_description    Uptime
    check_command        check_nt!UPTIME
        contact_groups          admins,SMS_GROUP
    }

=========================================================



Install NRPE On CentOS/Linux

1. Login to Client Server as root

2. create one sh file like below


vim install-nrpe.sh

## paste below as it is.

yum install openssl-devel gcc xinetd make glibc -y
yum install wget vim telnet htop -y
wget http://ufpr.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz
tar -xzf nrpe-2.14.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
tar -xzf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
useradd nagios
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make && make install
chown -R nagios:nagios /usr/local/nagios/libexec
cd ..
cd nrpe-2.14
./configure
make all && make install-plugin && make install-daemon && make install-daemon-config && make install-xinetd

:wq


chmod +x install-nrpe.sh && ./install-nrpe.sh

vim /etc/services

nrpe            5666/tcp                # NRPE

:wq


vim /etc/xinetd.d/nrpe

only_from       = 127.0.0.1 192.168.0.100

# Add nagios ip
192.168.0.100

# add nagios ip

:wq


service xinetd start && chkconfig xinetd on && chmod -R 777 /usr/local/nagios/libexec/* ; chown -R nagios:nagios /usr/local/nagios/libexec/*

vim /usr/local/nagios/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 4 -c 5
command[check_load]=/usr/local/nagios/libexec/check_load -w 75 -c 85
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 16% -c 15%
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 140 -c 150
command[check_mem]=/usr/local/nagios/libexec/check_mem -w 85 -c 90
command[check_cpu_perf]=/usr/local/nagios/libexec/check_cpu_perf
command[check_uptime]=/usr/local/nagios/libexec/check_uptime


:wq

vim /usr/local/nagios/libexec/check_cpu_perf
vim /usr/local/nagios/libexec/check_mem
cd /usr/local/nagios/libexec/ && chmod +x check_cpu_perf check_mem && chown nagios. check_cpu_perf check_mem && service xinetd restart

Wednesday, 4 May 2016

Install NRPE To Add Linux Server In Nagios


 # yum install openssl-devel gcc xinetd make glibc

# wget http://ufpr.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz
# tar -xzf nrpe-2.14.tar.gz

# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
tar -xzf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
useradd nagios
./configure --with-nagios-user=nagios --with-nagios-group=nagios

make && make install

chown -R nagios:nagios /usr/local/nagios/libexec

cd nrpe-2.14
./configure

make all

make install-plugin

make install-daemon

make install-daemon-config

make install-xinetd

vim /etc/services     

nrpe            5666/tcp                # NRPE

:wq


vim /etc/xinetd.d/nrpe 

only_from       = 127.0.0.1 192.168.0.102

# add nagios ip

:wq


service xinetd start

chkconfig xinetd on

chmod -R 777 /usr/local/nagios/libexec/* ; chown -R nagios:nagios /usr/local/nagios/libexec/*

cd /usr/local/nagios/etc/

vim nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 4 -c 5
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 16% -c 15%
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 140 -c 150
command[check_mem]=/usr/local/nagios/libexec/check_mem -w 65,24 -c 75,25
command[check_cpu_perf]=/usr/local/nagios/libexec/check_cpu_perf
command[check_uptime]=/usr/local/nagios/libexec/check_uptime


:wq

service xinetd restart

Tuesday, 8 March 2016

Monitor MySQL Via Nagios


Monitoring MySQL:

Step-7: Download, Extract and install the MySQL Plugin:

wget http://labs.consol.de/wp-content/uploads/2010/10/check_mysql_health-2.1.3.tar.gz

tar -zxvf check_mysql_health-2.1.3.tar.gz
cd check_mysql_health-2.1.3
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl
make
make install

Step-8: Create database user:

grant usage, replication client on *.* to 'nagios'@'localhost' identified by 'nagios';

Step-9: Provide email address for nagiosadmin:

[Change contacts.cfg file accordingly.]

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


define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Kedar ; Full name of user
email kedar@nitty-witty.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

Step-10: Configuring Nagios to Monitor MySQL Server

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

add following line:

cfg_file=/usr/local/nagios/etc/objects/mysqlmonitoring.cfg

Define check_mysql_health command as follows:

vi /usr/local/nagios/etc/objects/commands.cfg

define command{
command_name check_mysql_health
command_line $USER1$/check_mysql_health -H $ARG4$ --username $ARG1$ --password $ARG2$ --port $ARG5$ --mode $ARG3$
}

Enter services to be monitored in mysqlmonitoring.cfg:

vi /usr/local/nagios/etc/objects/mysqlmonitoring.cfg

Add:

define service{
use local-service
host_name localhost
service_description MySQL connection-time
check_command check_mysql_health!nagios!nagios!connection-time!127.0.0.1!3306!
}


define service{
use local-service
host_name localhost
service_description MySQL slave-io-running
check_command check_mysql_health!nagios!nagios!slave-io-running!127.0.0.1!3306!
}


define service{
use local-service
host_name localhost
service_description MySQL slave-sql-running
check_command check_mysql_health!nagios!nagios!slave-sql-running!127.0.0.1!3306!
}



define service{

    use             generic-service

    host_name         slavedb-192.168.0.250

    service_description     MySQL connection-time

    check_command check_mysql_health!nagiosadmin!nagiosadmin!connection-time!54.169.18.243!3306!

    contact_groups          admins

    }


    define service{

    use             generic-service

    host_name         slavedb-192.168.0.250

    service_description MySQL slave-io-running

    check_command check_mysql_health!nagiosadmin!nagiosadmin!slave-io-running!54.169.18.243!3306!

    contact_groups          admins

    }


    define service{

    use             generic-service

    host_name         slavedb-192.168.0.250

    service_description MySQL slave-sql-running

    check_command check_mysql_health!nagiosadmin!nagiosadmin!slave-sql-running!54.169.18.243!3306!

    contact_groups          admins

    }


define service{

    use             generic-service

    host_name         slavedb-192.168.0.250

    service_description     MySQL uptime

    check_command check_mysql_health!nagiosadmin!nagiosadmin!connection-time!54.169.18.243!3306!

    contact_groups          admins

    }


define service{

    use             generic-service

    host_name         slavedb-192.168.0.250

    service_description     MySQL threads-connected

    check_command check_mysql_health!nagiosadmin!nagiosadmin!connection-time!54.169.18.243!3306!

    contact_groups          admins

    }


define service{

    use             generic-service

    host_name         slavedb-192.168.0.250

    service_description     MySQL long-running-procs

    check_command check_mysql_health!nagiosadmin!nagiosadmin!connection-time!54.169.18.243!3306!

    contact_groups          admins

    }


  

define service{

    use             generic-service

    host_name         slavedb-192.168.0.250

    service_description     MySQL slow-queries

    check_command check_mysql_health!nagiosadmin!nagiosadmin!connection-time!54.169.18.243!3306!

    contact_groups          admins

    }



Note: Every time you change configuration file, verify before starting nagios using command:


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


Finally start nagios service and you’re done with nagios installation and configuration for monitoring MySQL.



Ref:


http://kedar.nitty-witty.com/blog/10-steps-mysql-monitoring-nagios-installation-configuration


https://labs.consol.de/nagios/check_mysql_health/




Add Windows Server In Nagios By Using SNMP Service


To add windows server in nagios:

1. Login to your windows server
2. Go to start --> Administrative tools --> Server Manager and install snmp service.
3. Go to service options from start --> administrative tools --> services
4. Right click SNMP service and select properties
5. Click security
6. Select "send authentication trap"
   Under accepted community names
7. Click add
8. Select commuity rights -> Read only
   Community name --> public
9. Click add
10.Select @ "accept SNMP packets from these hosts"
11. Add nagios server ip address
12.Click Apply --> ok
13.Restart snmp service

Note: If you see any by default ip then remove it.

go to nagios server and create hostname.cfg file and add services which you want to moniter

=====================

Now it’s time to define some object definitions in your Nagios configuration files in order to monitor the new Windows machine.

Open the windows.cfg file for editing.

    vi /usr/local/nagios/etc/objects/windows.cfg

Add a new host definition for the Windows machine that you’re going to monitor. If this is the *first* Windows machine you’re monitoring, you can simply modify the sample host definition in windows.cfg. Change the host_name, alias, and address fields to appropriate values for the Windows box.

    define host{
    use       windows-server ; Inherit default values from a Windows server template (make sure you keep this line!)
    host_name         winserver
    alias     My Windows Server
    address   192.168.1.2
    }

Replace “winserver” in the example definitions below with the name you specified in the host_name directive of the host definition you just added.

Now you can add some service definitions (to the same configuration file) in order to tell Nagios to monitor different aspects of the Windows machine. If this is the *first* Windows machine you’re monitoring, you can simply modify the sample service definitions in windows.cfg

Add the following service definition to monitor the version of the NSClient++ addon that is running on the Windows server. This is useful when it comes time to upgrade your Windows servers to a newer version of the addon, as you’ll be able to tell which Windows machines still need to be upgraded to the latest version of NSClient++.

    define service{
    use                        generic-service
    host_name                           winserver
    service_description        NSClient++ Version
    check_command              check_nt!CLIENTVERSION
    }

Add the following service definition to monitor the uptime of the Windows server.

    define service{
    use                        generic-service
    host_name                           winserver
    service_description        Uptime
    check_command              check_nt!UPTIME
    }

Add the following service definition to monitor the CPU utilization on the Windows server and generate a CRITICAL alert if the 5-minute CPU load is 90% or more or a WARNING alert if the 5-minute load is 80% or greater.

    define service{
    use                 generic-service
    host_name                    winserver
    service_description CPU Load
    check_command       check_nt!CPULOAD!-l 5,80,90
    }

Add the following service definition to monitor memory usage on the Windows server and generate a CRITICAL alert if memory usage is 90% or more or a WARNING alert if memory usage is 80% or greater.

    define service{
    use                       generic-service
    host_name                         winserver
    service_description       Memory Usage
    check_command             check_nt!MEMUSE!-w 80 -c 90
    }

Add the following service definition to monitor usage of the C:\ drive on the Windows server and generate a CRITICAL alert if disk usage is 90% or more or a WARNING alert if disk usage is 80% or greater.

    define service{
    use                      generic-service
    host_name                         winserver
    service_description      C:\ Drive Space
    check_command            check_nt!USEDDISKSPACE!-l c -w 80 -c 90
    }

Add the following service definition to monitor the uptime of the Windows server.

    define service{
    use                        generic-service
    host_name                           winserver
    service_description        Uptime
    check_command              check_nt!UPTIME
    }

Add the following service definition to monitor the CPU utilization on the Windows server and generate a CRITICAL alert if the 5-minute CPU load is 90% or more or a WARNING alert if the 5-minute load is 80% or greater.

define service{
use                 generic-service
host_name                    winserver
service_description CPU Load
check_command       check_nt!CPULOAD!-l 5,80,90
}

Add the following service definition to monitor memory usage on the Windows server and generate a CRITICAL alert if memory usage is 90% or more or a WARNING alert if memory usage is 80% or greater.

    define service{
    use                       generic-service
    host_name                         winserver
    service_description       Memory Usage
    check_command             check_nt!MEMUSE!-w 80 -c 90
    }

Add the following service definition to monitor usage of the C:\ drive on the Windows server and generate a CRITICAL alert if disk usage is 90% or more or a WARNING alert if disk usage is 80% or greater.

    define service{
    use                      generic-service
    host_name                         winserver
    service_description      C:\ Drive Space
    check_command            check_nt!USEDDISKSPACE!-l c -w 80 -c 90
    }

Password Protection

If you specified a password in the NSClient++ configuration file on the Windows machine, you’ll need to modify the check_nt command definition to include the password. Open the commands.cfg file for editing.

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

Change the definition of the check_nt command to include the “-s <PASSWORD>” argument (where PASSWORD is the password you specified on the Windows machine) like this:

    define command{
    command_name    check_nt
    command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s PASSWORD -v $ARG1$ $ARG2$
    }

Also publicly available services that are provided by Windows machines (HTTP, FTP, POP3, etc.) can be monitored easily by following commands,

A simple service definition for monitoring the HTTP service on the remotehost machine might look like this:

    define service{
    use               generic-service
    host_name                 remotehost
    service_description       HTTP
    check_command     check_http
    }

A simple service definition for monitoring the FTP server on remotehost would look like this:

    define service{
    use                generic-service
    host_name                  remotehost
    service_description        FTP
    check_command      check_ftp
    }

A simple service definition for monitoring the SMTP server on remotehost would look like this:

    define service{
    use                generic-service
    host_name                  remotehost
    service_description        SMTP
    check_command      check_smtp
    }

Save the file.

===========================================================
===========================================================
Examples:

define host{
        use                     windows-server
        host_name               www2.bccicricket.org
        alias                   www2.bccicricket.org
        address                 202.52.134.226
        }

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       www2.bccicricket.org
        service_description             PING
        normal_check_interval           15
        check_command                   check_ping!1000,40%!3000,80%
        }


define service{
        use                             generic-service
        host_name                       www2.bccicricket.org
        service_description             RDP
        check_command                   check_tcp!3389
        }


define service{
        use                             generic-service
        host_name                       www2.bccicricket.org
        service_description             FTP
        check_command                   check_tcp!21
        }

define service{
        use                             generic-service
        host_name                       www2.bccicricket.org
        service_description             SMTP
    check_command                   check_tcp!25
        }

define service{
        use                             generic-service
        host_name                       www2.bccicricket.org
        service_description             DNS
        check_command                   check_tcp!53
        }


define service{
        use                             generic-service
        host_name                       www2.bccicricket.org
        service_description             HTTP
        check_command                   check_tcp!80
        }


define service{
        use                             generic-service
        host_name                       www2.bccicricket.org
        service_description             POP3
        check_command                   check_tcp!110
        }


define service{
        use                             generic-service
        host_name                       www2.bccicricket.org
        service_description             IMAP
        check_command                   check_tcp!143
        }


define service{
        use                             generic-service
        host_name                       www2.bccicricket.org
        service_description             RBL
        check_command                   check_rbl
        }

define service {
        use                             generic-service         ; Name of service template to use
        host_name                       www2.bccicricket.org
        service_description             CPU
        check_command                   check_win_cpu
}

define service {
        use                             generic-service         ; Name of service template to use
        host_name                       www2.bccicricket.org
        service_description             Memory
        check_command                   check_win_mem!90!95
}

define service {
        use                             generic-service         ; Name of service template to use
        host_name                       www2.bccicricket.org
        service_description             Uptime
        check_command                   check_win_uptime
}

define service {
        use                             generic-service         ; Name of service template to use
        host_name                       www2.bccicricket.org
        service_description             Updates
        check_command                   check_win_update
}

define service {
        use                             generic-service         ; Name of service template to use
        host_name                       www2.bccicricket.org
        service_description             Load
        check_command                   check_snmp_load!stand!60!70
}

define service {
        use                             generic-service         ; Name of service template to use
        host_name                       www2.bccicricket.org
        service_description             C:
        check_command                   check_snmp_disk!C:!80!90
}

define service {
        use                             generic-service         ; Name of service template to use
        host_name                       www2.bccicricket.org
        service_description             SWAP
        check_command                   check_snmp_disk!Virtual!80!90
}

:wq

name should be hostname.cfg





Add Website In Nagios

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       www.experiencesilk.com
        service_description             PING
        normal_check_interval           15
        check_command                   check_ping!1000,40%!3000,80%
        }

define service{
        use                             generic-service
        host_name                       www.experiencesilk.com
        service_description             CONTENT_CHECK
        check_command                   check_http_content!www.experiencesilk.com!/home.php?fl=1!India
        }



For Example:

http://www.analyseindia.com/analyseindia/testPager.jsp

http://experiencesilk.com/home.php


#define service{
#        use                             generic-service
#        host_name                       mtv.in.com-curiousminds
#        service_description             CONTENT_CHECK
#        check_command                   check_http!-H www.mtv.in.com -u "/curiousminds/index.php" -f follow -s "Curious"
#        }

define service{
        use                             generic-service
        host_name                       mtv.in.com-curiousminds
        service_description             CONTENT_CHECK
        check_command                   check_http_content!www.mtv.in.com!/curiousminds/index.php?fl=1!Curious
        }

Nagios Service Templates

define host{
        use                     linux-server
        host_name               krrish-3.com
        alias                   krrish
        address                 202.52.134.137
        contact_groups          admins
    parents            dhruv
        hostgroups              Linux
        }

define service{
        use                     generic-service
        host_name               krrish-3.com
        service_description     PING
        check_command           check_ping!1000.0,40%!3000.0,80%
        }

define service{
        use                             generic-service
        host_name                       krrish-3.com
        service_description             SSH
        check_command                   check_ssh
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        normal_check_interval           15
        service_description             LOAD
        check_command                   check_nrpe!check_load
        }

define service{
        use                             generic-service-300
        host_name                       s1.watconsult.com
        service_description             DISK
        check_command                   check_nrpe!check_disk
       }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        normal_check_interval           15
        service_description             PROCESSES
        check_command                   check_nrpe!check_total_procs
        }

#define service{
#        use                             generic-service
#        host_name                       s1.watconsult.com
#        normal_check_interval           30
#        service_description             USERS
#        check_command                   check_nrpe!check_users
#        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        normal_check_interval           30
        service_description             RAID Status
        check_command                   check_nrpe!check_raid
       }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             Uptime
        check_command                   check_nrpe!check_uptime
       }
define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             CPU
        check_command                   check_nrpe!check_cpu_perf
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             Memory
        check_command                   check_nrpe!check_mem
        }

define service{
    use                       generic-service       
    host_name                   s1.watconsult.com
    service_description            FTP
    check_command                   check_ftp
    }


define service{
    use                      generic-service
    host_name              s1.watconsult.com
    service_description          HTTP
    check_command                  check_http
    }

define service{
    use                     generic-service
    host_name             s1.watconsult.com
    service_description         SMTP
    check_command                 check_smtp
    }

define service{
        use                     generic-service
        host_name             s1.watconsult.com
    service_description         POP3
    check_command                 check_pop
    }

define service{
    use                     generic-service
    host_name            s1.watconsult.com
    service_description        IMAP
    check_command                check_imap
    }

====================================================================


define host{
        use                     linux-server
        host_name               smtpout.airpayme.com
        alias                   watconsult
        address                 202.52.134.21
        contact_groups          admins
    parents            dhruv
        hostgroups              Linux
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             PING
        check_command                   check_ping!1000,40%!3000,80%
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        normal_check_interval           15
        service_description             LOAD
        check_command                   check_nrpe!check_load
        }

define service{
        use                             generic-service-300
        host_name                       s1.watconsult.com
        service_description             DISK
        check_command                   check_nrpe!check_disk
        }
define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        normal_check_interval           15
        service_description             PROCESSES
        check_command                   check_nrpe!check_total_procs
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             FTP
        check_command                   check_tcp!21
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             SMTP
        check_command                   check_tcp!25
        }


define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             DNS
        check_command                   check_tcp!53
        }


define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             HTTP
        check_command                   check_tcp!80
        }


define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             POP3
        check_command                   check_tcp!110
        }


define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             IMAP
        check_command                   check_tcp!143
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             HTTPS
        check_command                   check_tcp!443
        }


define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             SMTPS
        check_command                   check_tcp!465
        }


define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             SUBMISSION
        check_command                   check_tcp!587
        }


define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             IMAPS
        check_command                   check_tcp!993
        }


define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             POP3S
        check_command                   check_tcp!995
        }


define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        service_description             MYSQL
        check_command                   check_tcp!3306
        }

define service{
        use                             generic-service-300
        host_name                       s1.watconsult.com
        service_description             RBL
        check_command                   check_rbl
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        normal_check_interval           15
        service_description             LOAD
        check_command                   check_nrpe_vz!202.52.134.21!check_load_mail
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        normal_check_interval           15
        service_description             DISK
        check_command                   check_nrpe_vz!202.52.134.21!check_disk_mail
        }

define service{
        use                             generic-service
        host_name                       s1.watconsult.com
        normal_check_interval           15
        service_description             PROCESSES
        check_command                   check_nrpe_vz!202.52.134.21!check_total_procs_mail
        }

NRPE Installtion CentOS

NRPE Installtion CentOS:


Download nagios plugins and nrpe package

[Link:- http://kaz.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz]

[root@tlv8 downloads]# tar -xvzf nagios-plugins-1.4.16.tar.gz

[root@tlv8 downloads]# cd nagios-plugins-1.4.16

[root@tlv8 nagios-plugins-1.4.16]# useradd nagios

[root@tlv8 nagios-plugins-1.4.16]# yum install openssl-devel gcc

[root@tlv8 nagios-plugins-1.4.16]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

[root@tlv8 nagios-plugins-1.4.16]# make (if it gives error make command not found )

optional [root@tlv8 nagios-plugins-1.4.16]# yum install make

[root@tlv8 nagios-plugins-1.4.16]# make install

[root@tlv8 nagios-plugins-1.4.16]# chown -R nagios:nagios /usr/local/nagios/libexec

[root@tlv8 nagios-plugins-1.4.16]# cd ..

Download NRPE Package:
Link:-  http://kaz.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz]

[root@tlv8 downloads]# tar -xvzf nrpe-2.14.tar.gz

[root@tlv8 downloads]# cd nrpe-2.14

[root@tlv8 nrpe-2.14]# ./configure

[root@tlv8 nrpe-2.14]# make all

[root@tlv8 nrpe-2.14]# make install-plugin

[root@tlv8 nrpe-2.14]# make install-daemon
[root@tlv8 nrpe-2.14]# make install-daemon-config
[root@tlv8 nrpe-2.14]# make install-xinetd
[root@tlv8 nrpe-2.14]# vi /etc/xinetd.d/nrpe ( add nagios ip on line allow from i.e. - 202.52.134.101)

[root@tlv8 nrpe-2.14]# vi /etc/services ( add this line at the end of file:- nrpe            5666/tcp                # NRPE )

[root@tlv8 nrpe-2.14]# chkconfig xinetd on
(if it gives below error :
error reading information on service xinetd: No such file or directory then install xinetd by:- yum install xinetd )

[root@tlv8 nrpe-2.14]# service xinetd restart

[root@tlv8 nrpe-2.14]# netstat -at |grep nrpe [ check nrpe port is open ]

[root@tlv8 nrpe-2.14]# /usr/local/nagios/libexec/check_nrpe -H localhost [ check nrpe is working ]

CHECK_NRPE: Error – Could not complete SSL handshake

Solution:-
check if in vi /etc/xinetd.d/nrpe
  allowed_from=  check nagios server ip

add nrpe command in below location

[root@server~]# /usr/local/nagios/libexec
keep here all nagios command which you want to monitored

Like  check_disk  check_dhcp

[root@server~]# vi /usr/local/nagios/etc/nrpe.cfg

add here below command which you want to monitored

like
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 1000 -c 1200
command[check_raid]=/usr/local/nagios/libexec/check_raid
command[check_yum]=sudo /usr/local/nagios/libexec/check_yum
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10%
command[check_md_raid]=sudo /usr/local/nagios/libexec/check_md_raid
command[check_mem]=/usr/local/nagios/libexec/check_mem -w 90,25 -c 95,50
command[check_cpu_perf]=sudo /usr/local/nagios/libexec/check_cpu_perf
command[check_uptime]=/usr/local/nagios/libexec/check_uptime

:wq


restart xinetd services


after above process complete then go to nagios server

create configuration file for monitored services
keep name is hostname.cfg

restart nagios service

HOW TO ADD OPEN VZ VPS IN NAGIOS
=================================

1. Not need to install nrpe on vps.
2. from hardware node :-copy nagios/ folder to vps /usr/local/
3. on hardware node:- add /usr/local/nagios/etc/nrpe.cfg

add below command

#smtpout    <-- vps hostname for indentification

command[check_disk_smtpout]=sudo /usr/sbin/vzctl exec2 145 /usr/local/nagios/libexec/check_disk -w 20% -c 10% -p / 2>&1
command[check_total_procs_smtpout]=sudo /usr/sbin/vzctl exec2 145 /usr/local/nagios/libexec/check_procs -w 100 -c 120 2>&1
command[check_load_smtpout]=sudo /usr/sbin/vzctl exec2 145 /usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20 2>&1


:wq


[syntax for example]
command[check_load_vpshostname]=sudo /usr/sbin/vzctl exec2 vps_id /usr/local/nagios/libexec/check_disk -w 20% -c 10% -p / 2>&1

finally go to nagios server
create hostname.cfg file and add service which you want to monitor

HOW TO ADD OPEN VZ VPS IN NAGIOS

HOW TO ADD OPEN VZ VPS IN NAGIOS
==========================

1. Not need to install nrpe on vps.
2. from hardware node :-copy nagios/ folder to vps /usr/local/
3. on hardware node:- add /usr/local/nagios/etc/nrpe.cfg

add below command

#smtpout    <-- vps hostname for indentification

command[check_disk_smtpout]=sudo /usr/sbin/vzctl exec2 145 /usr/local/nagios/libexec/check_disk -w 20% -c 10% -p / 2>&1
command[check_total_procs_smtpout]=sudo /usr/sbin/vzctl exec2 145 /usr/local/nagios/libexec/check_procs -w 100 -c 120 2>&1
command[check_load_smtpout]=sudo /usr/sbin/vzctl exec2 145 /usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20 2>&1


:wq

restart service xinetd

[syntax for example]
command[check_load_vpshostname]=sudo /usr/sbin/vzctl exec2 vps_id /usr/local/nagios/libexec/check_disk -w 20% -c 10% -p / 2>&1

finally go to nagios server
create hostname.cfg file and add service which you want to monitor

Nagios Error & Solutions

file:///home/namdev/Desktop/FC/ADMIN-TASK/NOTES/Admin-FC/MONITORING/NAGIOS/Nagios-Done/Error%20&%20Solutions/2%20Error%20while%20resheduling%20service.png

Solutions :

Assign full permission to file nagios.cmd file.

# chmod 777 /usr/local/nagios/var/rw/nagios.cmd


file:///home/namdev/Desktop/FC/ADMIN-TASK/NOTES/Admin-FC/MONITORING/NAGIOS/Nagios-Done/Error%20&%20Solutions/Nagios%20CGI%20Error.png




To configure and install nagios link is :-
http://www.thegeekstuff.com/2008/05/nagios-30-jumpstart-guide-for-red-hat-overview-installation-and-configuration/

-----------------------------------------------------------------------------

when your trying to add the service of nagios in chkconfig by using following command then sometime you will get error such as:

[root@anup ~]# chkconfig --add nagios
error reading information on service nagios: No such file or directory
[root@anup ~]#

-----------------------------------------------------------------------------
To solve this error Go to the directory where you have install nagios and use following command:

[root@anup nagios-3.0.1]# make install-init
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios

*** Init script installed ***
[root@anup nagios-3.0.1]#

-----------------------------------------------------------------------------
The try to add the service of nagios i hope i will work

[root@anup nagios-3.0.1]# chkconfig --add nagios
[root@anup nagios-3.0.1]# service nagios restart
Running configuration check...done.
Stopping nagios: .done.
Starting nagios: done.
[root@anup nagios-3.0.1]#
[root@anup nagios-3.0.1]# chkconfig nagios on
-----------------------------------------------------------------------------

Here if you get Error:
“You don’t have permission to access /nagios/ on this server.”

Check /etc/httpd/conf/httpd.conf for DirectoryIndex.
If it’s not having index.php add it as follows:

vi /etc/httpd/conf/httpd.conf
DirectoryIndex index.php index.html index.html.var

Make sure you do restart apache(httpd) and nagios every time you change the config file. You must have php installed.
-----------------------------------------------------------------------------

IF YOU GET ERROR:-
=======================================
It appears as though you do not have permission to view information for any of the hosts you requested...
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI
and check the authorization options in your CGI configuration file.
===================================
SOLUTION:-
EDIT BELOW CGI LINE
# vim /usr/local/nagios/etc/cgi.cfg
add user name
:wq

# service nagios restart
==========================================
Nagios Error and Solution

Error :- sudo: sorry, you must have a tty to run sudo
Solution:- 

    [root@server~]# vi /etc/sudoers
    comment #Defaults    requiretty
    and add below lines at end of file
      # %users  localhost=/sbin/shutdown -h now
       nagios  ALL=(ALL) NOPASSWD: /usr/local/nagios/libexec/
       nagios  ALL=(ALL) NOPASSWD: /usr/sbin/vzctl
:wq

[root@server~]# service xinetd restart



Nagios Monitoring System Installation In CentOS


NAGIOS INSTALLATION IN CENTOS 6.7
===========================

[root@server~]# yum install httpd* php* gcc* glibc* glibc-common* gd* gd-devel*
[root@server~]# /usr/sbin/useradd -m nagios
[root@server~]# passwd nagios
[root@server~]# /usr/sbin/groupadd nagcmd
[root@server~]# /usr/sbin/usermod -a -G nagcmd nagios
[root@server~]# /usr/sbin/usermod -a -G nagcmd apache
[root@server~]# mkdir ~/downloads
[root@server~]# cd ~/downloads
[root@server~]# wget http://citylan.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.4.4/nagios-3.4.4.tar.gz
[root@server~]# wget http://citylan.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
[root@server~]# wget http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2172&cf_id=24                       ---> latest packge for theme
[root@server~]# cd ~/downloads
[root@server~]# tar xzf nagios-3.3.1.tar.gz
[root@server~]# cd nagios-3.3.1
 
 Run the Nagios configure script, passing the name of the group you created earlier like so:
[root@server~]# ./configure --with-command-group=nagcmd

Compile the Nagios source code.

[root@server~]# make all

Install binaries, init script, sample config files and set permissions on the external command directory.

[root@server~]# make install
[root@server~]# make install-init
[root@server~]# make install-config
[root@server~]# make install-commandmode

Set Permission

[root@server~]# chown nagios.nagios /usr/local/nagios
[root@server~]# chown -R nagios.nagios /usr/local/nagios/libexec/

Don't start Nagios yet - there's still more that needs to be done...
Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory.

[root@server~]# make install-webconf

Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.

[root@server~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache to make the new settings take effect.
[root@server~]# service httpd restart

Extract the Nagios plugins source code tarball.
[root@server~]# cd ~/downloads
[root@server~]# tar xzf nagios-plugins-1.4.15.tar.gz
[root@server~]# cd nagios-plugins-1.4.15

Compile and install the plugins.

[root@server~]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@server~]# make
[root@server~]# make install

Add Nagios to the list of system services and have it automatically start when the system boots.

[root@server~]# chkconfig --add nagios
[root@server~]# chkconfig nagios on

For getting alert via email to admin

[root@server~]# vi /usr/local/nagios/etc/objects/contacts.cfg

email     nagios@localhost   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

:wq

Verify the sample Nagios configuration files.

[root@server~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios.

[root@server~]# service nagios start

8) Modify SELinux Settings

Fedora ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs.

See if SELinux is in Enforcing mode.

[root@server~]# getenforce

Put SELinux into Permissive mode.

[root@server~]# setenforce 0

To make this change permanent, you'll have to modify the settings in /etc/selinux/config and reboot.

Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode:

[root@server~]# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
[root@server~]# chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

ADD NAGIOS USER THOSE YOU ABOVE CREATED FOR ACCESS NAGIOS WEB INTERFACE
[root@server~]# /usr/local/nagios/etc/cgi.cfg
[you need to change user nagiosadmin <-- user name]

start service
[root@server~]# service httpd restart
[root@server~]# service nagios restart

cd /usr/local/nagios/etc/
vim nagios.cfg

###  add below line here #####
# Definitions for monitoring the local (Linux) host
  35 cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

cfg_dir=/usr/local/nagios/etc/servers

:wq

cd /usr/local/nagios/etc/objects

vim commands.cfg

define command{
    command_name    check_nrpe
    command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 60
}

:wq


service nagios restart


TO ACCESS NAGIOS FROM BROWSER
http://hostname/nagios   or  http://serverip/nagios


Note :  Make the changes in cgi.cfg file and put the user name created in htpasswd.users file.

FOR NEW THEME INSTALLATION
1. go to location /usr/local/nagios/share
2. download new theme
wget http://sourceforge.net/projects/arana-nagios/files/arana_style-1.0for-Nagios3x-ENG.zip/download

3. unzip new theme here [extract file here.]
Note:- first take backup already present file and remove it
       unzip new theme file /usr/local/nagios/shre
4. Nagios restart


TO ACCESS NAGIOS FROM BROWSER
 http://ip-addr/nagios  or ip-addr/nagios

===================================================


FOR CHANGE NAGIOS HEADER
========================
# vim /usr/local/nagios/share
and edit index.html, index.php,top.html & sidebar.html  file
# service nagios restart

HOW TO CHANGE NAGIOS LOGO
Replace Image designby.png from /usr/local/nagios/share/images/interface/   download any of your choices images. Name of image should be "designby.png"
# service nagios restart

=======================================================

IF YOU GET ERROR:-
==========================================================
It appears as though you do not have permission to view information for any of the hosts you requested...
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI
and check the authorization options in your CGI configuration file.
==========================================================
SOLUTION:-
EDIT BELOW CGI LINE
# vim /usr/local/nagios/etc/cgi.cfg
add user name
:wq

# service nagios restart
==========================================
Nagios Error and Solution

Error :- sudo: sorry, you must have a tty to run sudo
Solution:- 
 
    [root@server~]# vi /etc/sudoers
    comment #Defaults    requiretty
    and add below lines at end of file
      # %users  localhost=/sbin/shutdown -h now
       nagios  ALL=(ALL) NOPASSWD: /usr/local/nagios/libexec/
       nagios  ALL=(ALL) NOPASSWD: /usr/sbin/vzctl
:wq

[root@server~]# service xinetd restart

Enjoy

Verifying Nagios Configuration

[root@server~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg




=====================================================
ps -aufx find /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg and kill
and again /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg.

=====================================================
=====================================================