Tuesday, 8 March 2016

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





No comments: