Nagios Monitoring linux and windows host with snmp

Documention for nagios
###########################################################################
The following documentation assusmes that you ave already got a nagios server installed frm nagios.org .
###########################################################################

install the net snmp package on you nagios server ( if not already installed )
yum install net-snmp-devel

download the snnm plugin for nagios
cd /usr/local/src
http://nagios.manubulon.com/nagios-plugins-snmp-0.6.0.tgz

./configure --prefix=/usr/local/nagios
make
make install


############################################################################

the snmp.conf flile should look some thing like this the community string is public

snmpd.conf

# For more information, read the FAQ as well as the snmpd.conf(5)
# manual page.
## sec.name source community
## ======== ====== =========
com2sec local localhost public
com2sec network_1 211.85.43.0/24 public
#com2sec network_2 192.168.2.0/24 public

## Access.group.name sec.model sec.name
## ================= ========= ========
group MyROGroup_1 v1 local
group MyROGroup_1 v1 network_1
group MyROGroup_2 v2c network_2

## MIB.view.name incl/excl MIB.subtree mask
## ============== ========= =========== ====
view all-mibs included .1 80
#view all included .1 80
#view system included .iso.org.dod.internet.mgmt.mib-2.system

## MIB
## group.name context sec.model sec.level prefix read write notif
## ========== ======= ========= ========= ====== ==== ===== =====
access MyROGroup_1 "" v1 noauth exact all-mibs none none
access MyROGroup_2 "" v2c noauth exact all-mibs none none


The Following is the command will help you to find ou the OID of the host that you going to query in the future !!

snmpwalk ip_address -v1 -c public > /tmp/temfile.txt


Following is the command to check process running on Linux host.

1) this will chk if the etho link is up or not
./check_snmp_int -H linuxhost -C public -n eth0 -r

2) to check uptime fo the machine
./check_snmp -H linuxhost -C public -o sysUpTimeInstance

3) to check CPU load ( 5 min )
./check_snmp -H linuxhost -C notification -o hrProcessorLoad.1 -w 80 -c 90

4.) to check disk space ( / , /home, /usr, ) do also ( snmpwalk linuxhost -v1 -c public hrStorageDescr ) to find out the partition list
./check_snmp_storage -H linuxhost -C notification -m /home -w 80% -c 90%

5) to check smtp
./check_smtp -H linuxhost -C public -w 10 -c 20

6) to check pop
./check_pop -H linuxhost -C public -w 10 -c 20

7) to check imap
./check_imap -H linuxhost -C public -w 10 -c 20


Following is the command to check process running on windows host.

1) this will chk if the etho link is up or not
./check_snmp -H windowshost -C notification -o ifDescr.2

2) to check uptime fo the machine
/check_snmp -H windowshost -C notification -o sysUpTimeInstance

3) to check CPU load ( 5 min )
./check_snmp -H windowshost -C public -o 1.3.6.1.4.1.2021.10.1.3.2

4) to check is /home disk space
./check_snmp_storage -H windowshost -C public -m /home -w 80% -c 90%

5) Swap % used is less than 80% and 90%
./check_snmp_storage -H windowshost -C public -m Swap -w 80% -c 90%

6) to check smtp
./check_smtp -H windowshost -C public -w 10 -c 20

7) to check pop
./check_pop -H windowshost -C public -w 10 -c 20

8) to check imap
./check_imap -H windowshost -C public -w 10 -c 20


Now we need chk if the following is added in the command.cfg

# 'check_snmp' command definition
define command{
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o $ARG2$
}

# 'check_http' command definition
define command{
command_name check_http
command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
}

# 'check_http' command definition
define command{
command_name check_http_tmp
command_line $USER1$/check_http -H $ARG1$
}

# 'check_pop' command definition
define command{
command_name check_pop
command_line $USER1$/check_pop -H $HOSTADDRESS$ $ARG1$
}


# 'check_imap' command definition
define command{
command_name check_imap
command_line $USER1$/check_imap -H $HOSTADDRESS$ $ARG1$
}


# 'check_smtp' command definition
define command{
command_name check_smtp
command_line $USER1$/check_smtp -H $HOSTADDRESS$ $ARG1$
}

#'check_snmp_int' if link is up
define command{
command_name check_snmp_int
command_line $USER1$/check_snmp_int -H $HOSTADDRESS$ -C $ARG1$ -n $ARG2$ -r
}

#'check_snmp_storage' storage space
define command{
command_name check_snmp_storage
command_line $USER1$/check_snmp_storage -H $HOSTADDRESS$ -C $ARG1$ -m $ARG2$ -w 80% -c 90%
}

Need to add the followin in the windows.cfg ( for windows host only )

############################# Hosts ###########################################
define host{
use linux-server ; Inherit default values from a Windows server template (make sure you keep this line!)
host_name server74
alias server74.dns.org
address windows_ipaddress
}
##############################################################################



define service{
use generic-service
host_name server89
service_description CPU load
check_command check_snmp!notification!hrProcessorLoad.1! -w 80 -c 90
}



# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name server89
service_description Uptime
check_command check_snmp!notification!sysUpTimeInstance
}

define service{
use generic-service
host_name server89
service_description ethernet link test
check_command check_snmp!notification!ifDescr.2
}

define service{
use generic-service
host_name server89
service_description check disk c drive
check_command check_snmp_storage!notification!^C:
}

define service{
use generic-service
host_name server89
service_description httpd service
check_command check_http_tmp!compose.company.com!-w 10 -c 20
}

define service{
use generic-service
host_name server89
service_description smtp service
check_command check_smtp!!-w 10 -c 20
}

define service{
use generic-service
host_name server89
service_description pop service
check_command check_pop!!-w 10 -c 20
}

define service{
use generic-service
host_name server89
service_description IMAP service
check_command check_imap!!-w 10 -c 20
}


Need to add the following in the the linux.cfg ( for linux host only )

############################# Hosts ###########################################
define host{
use linux-server ; Inherit default values from a Windows server template (make sure you keep this line!)
host_name server74
alias server74.dns.org
address linuxhost_ipaddress
}
##############################################################################

define service{
use generic-service
host_name server74
service_description CPU load
check_command check_snmp!public!.1.3.6.1.4.1.2021.10.1.3.2
}



# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name server74
service_description Uptime
check_command check_snmp!public!.1.3.6.1.2.1.1.3.0
}

define service{
use generic-service
host_name server74
service_description ethernet link test
check_command check_snmp_int!public!eth0
}

define service{
use generic-service
host_name server74
service_description check disk /home
check_command check_snmp_storage!public!home
}

define service{
use generic-service
host_name server74
service_description check disk /
check_command check_snmp_storage!public!/
}

define service{
use generic-service
host_name server74
service_description check disk /var
check_command check_snmp_storage!public!/var
}

define service{
use generic-service
host_name server74
service_description check disk /usr
check_command check_snmp_storage!public!/usr
}

define service{
use generic-service
host_name server74
service_description check disk /backup
check_command check_snmp_storage!public!/backup
}

define service{
use generic-service
host_name server74
service_description httpd service
check_command check_http!!-w 10 -c 20
}

define service{
use generic-service
host_name server74
service_description smtp service
check_command check_smtp!!-w 10 -c 20
}

define service{
use generic-service
host_name server74
service_description pop service
check_command check_pop!!-w 10 -c 20
}

define service{
use generic-service
host_name server74
service_description IMAP service
check_command check_imap!!-w 10 -c 20
}



No comments:

Other Articles

Enter your email address: