IT How Tos

Home

About

Sitemap

Contact

SNMP and Nagios

On Server to be monitored install SNMP

  • centos - net-snmp
  • ubuntu - snmpd snmp
  • Please google and double check this

Configure SNMP

  • Under /etc/snmp/snmpd.conf
    • replace $HOSTNAME with hostname
rocommunity  public
disk  / 80%
disk  /boot 80%
load  12 12 12
com2sec notConfigUser  default       public
group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
access  notConfigGroup ""      any       noauth    exact  systemview none none
sysName $HOSTNAME

Configure Nagios on Monitoring Server

Commands

  • Under etc/objects/commands.cfg
    • Alternatively create a new config etc/objects/commands.cfg

####### Definition #######

define command{
        command_name    check_snmp
        command_line    $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}

####### CPU ###############

define command{
        command_name    snmp_1m_cpu
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.10.1.3.1 -H $HOSTADDRESS$ $ARG1$
}

define command{
        command_name    snmp_5m_cpu
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.10.1.3.2 -H $HOSTADDRESS$ $ARG1$
}

define command{
        command_name    snmp_15m_cpu
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.10.1.3.3 -H $HOSTADDRESS$ $ARG1$
}

####### RAM/Swap Usage #########

define command{
        command_name    snmp_SwapSize
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.4.3.0 -H $HOSTADDRESS$ $ARG1$
}

define command{
        command_name    snmp_SwapFree
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.4.4.0 -H $HOSTADDRESS$ $ARG1$
}

define command{
        command_name    snmp_RamSize
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.4.5.0 -H $HOSTADDRESS$ $ARG1$
}

define command{
        command_name    snmp_RamFree
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.4.11.0 -H $HOSTADDRESS$ $ARG1$
}

###### Uptime #########

define command{
        command_name    snmp_Uptime
        command_line    $USER1$/check_snmp -o .1.3.6.1.2.1.1.3.0 -H $HOSTADDRESS$ $ARG1$
}

###### Disk Usage ######

#Get the mount point of the first disk
define command{
        command_name    snmp_Disk1_Mount
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.2.1 -H $HOSTADDRESS$ $ARG1$
}

#Get the size of the first disk
define command{
        command_name    snmp_Disk1_Size
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.6.1 -H $HOSTADDRESS$ $ARG1$
}

#Get the usage of the first disk
define command{
        command_name    snmp_Disk1_Usage
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.8.1 -H $HOSTADDRESS$ $ARG1$
}

#Get the usage as a percentage of the first disk
define command{
        command_name    snmp_Disk1_UsedPercentage
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.9.1 -H $HOSTADDRESS$ $ARG1$
}
 
#Get the mount point of the second disk
define command{
        command_name    snmp_Disk2_Mount
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.2.2 -H $HOSTADDRESS$ $ARG1$
}

#Get the size of the second disk
define command{
        command_name    snmp_Disk2_Size
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.6.2 -H $HOSTADDRESS$ $ARG1$
}

#Get the usage of the second disk
define command{
        command_name    snmp_Disk2_Usage
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.8.2 -H $HOSTADDRESS$ $ARG1$
}

#Get the usage as a percentage of the second disk
define command{
        command_name    snmp_Disk2_UsedPercentage
        command_line    $USER1$/check_snmp -o .1.3.6.1.4.1.2021.9.1.9.2 -H $HOSTADDRESS$ $ARG1$
}

Configuring the services

  • Under etc/objects/services.cfg
    • Alternatively create a new config etc/objects/snmpservices.cfg

###### CPU Usage ##########

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     CPU 1 Minute Average
        check_command           snmp_1m_cpu!-C public
}

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     CPU 5 Minute Average
        check_command           snmp_5m_cpu!-C public
}

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     CPU 15 Minute Average
        check_command           snmp_15m_cpu!-C public
}

###### RAM/Swap Usage ########

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Swap Size
        check_command           snmp_SwapSize!-C public
}

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Swap Free
        check_command           snmp_SwapFree!-C public
}
 

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     RAM Size
        check_command           snmp_RamSize!-C public
}

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     RAM Free
        check_command           snmp_RamFree!-C public
}

###### Disk Usage ##########

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Disk 1 Mountpoint
        check_command           snmp_Disk1_Mount!-C public
}

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Disk 2 Mountpoint
        check_command           snmp_Disk2_Mount!-C public
}

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Disk 1 Size
        check_command           snmp_Disk1_Size!-C public
}

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Disk 2 Size
        check_command           snmp_Disk2_Size!-C public
}

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Disk 1 Usage
        check_command           snmp_Disk1_Usage!-C public
}
define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Disk 2 Usage
        check_command           snmp_Disk2_Usage!-C public
}

define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Disk 1 Usage Percentage
        check_command           snmp_Disk1_UsedPercentage!-C public
}
define service{
        use                     generic-service
        hostgroup_name          snmp-servers
        service_description     Disk 2 Usage Percentage
        check_command           snmp_Disk2_UsedPercentage!-C public
}

Defining the Hosts

  • Under etc/objects/hosts.cfg
    • Alternatively create a new config etc/objects/snmphosts.cfg

##### SNMP Hosts ########

## Example ##

define host{
use linux-server
host_name $SNMP_HOST_TO_CHECK
alias $ALIAS
address $HOST_TO_CHECK_IP
hostgroups snmp-servers
}

Host Groups

  • Under Host Groups etc/objects/hostgroups.cfg
    • Alternatively under etc/objects/snmphostgroups.cfg
define hostgroup{
        hostgroup_name          snmp-servers
        alias                   SNMP Servers
        }

Add the config files

  • Under etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/snmpcommands.cfg
cfg_file=/usr/local/nagios/etc/objects/snmpservices.cfg
cfg_file=/usr/local/nagios/etc/objects/snmphostgroups.cfg
cfg_file=/usr/local/nagios/etc/objects/snmphosts.cfg

Alternative Documentation