Nagios monitoring 4 configuration monitoring web Service, port, mysql, and other status instances
1. monitoring web Services
(1) edit services. cfg to define the service
Define service {
Use generic-service
Host_name 5-nagios-server
Service_description weburl
Check_command check_weburl! -H 5.nagios.com-u/data/
}
(2) edit/etc/hosts and configure local domain name resolution
172.20.10.5 5.nagios.com
172.20.10.6 6.nagios.com
(3) EDIT commands. cfg and define the command
Define command {
Command_name check_weburl
Command_line $ USER1 $/check_http $ ARG1 $-w 10-c 30
/Etc/init. d/nagios checkconfig
/Etc/init. d/nagios reload
2. Active mode monitoring port
(1) vi services. cfg
Define service {
Use generic-service
Host_name 5-nagios-server
Service_description port_80
Check_command check_port! -H 5.nagios.com-p 80
(2) vi commands. cfg
Define command {
Command_name check_port
Command_line $ USER1 $/check_tcp $ ARG1 $-w 10-c 30
}
3. Monitoring port service in passive mode
(1). vi services. cfg
Define service {
Use generic-service
Host_name 6-nagios-client
Service_description port_80_beidong
Check_command check_nrpe! Check_port_80
}
(2) EDIT nrpe. cfg on the client
Command [check_port_80] =/usr/local/nagios/libexec/check_tcp-H 172.20.10.6-p 80
Nagios Return Value
STATE_ OK = 0
STATE_WARNING = 1
STATE_CRITICAL = 2
STATE_UNKNOWN = 3
STATE_DEPENDENT = 4
4. Verify that the/etc/passwd content has been modified.
Md5sum/etc/passwd>/etc/oldboy. md5
[Root @ client01 etc] # cat/usr/local/nagios/libexec/check_passwd
#! /Bin/bash
Char = 'md5sum-c/etc/oldboy. md5 2>/dev/null | grep "OK" | wc-l'
If [$ char-eq 1]; then
Echo "passwd is OK! "
Exit 0
Else
Echo "passwd is changed! "
Exit 2
Fi
Edit nrpe. cfg
Command [check_passwd] =/usr/local/nagios/libexec/check_passwd
Edit services. cfg on the server
Define service {
Use generic-service
Host_name 6-nagios-client
Service_description check_passwd
Check_command check_nrpe! Check_passwd
}
/Etc/init. d/nagios checkconfig
/Etc/init. d/nagios reload