| 知乎專欄 | 多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者” |
vim /etc/nagios3/routers/firewall.cfg
define host{
use generic-host; Inherit default values from a template
host_name firewall ; The name we're giving to this switch
alias Cisco PIX 515E Firewall ; A longer name associated with the switch
address 172.16.1.254 ; IP address of the switch
hostgroups all,networks ; Host groups this switch is associated with
}
define service{
use generic-service ; Inherit values from a template
host_name firewall ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}
define service{
use generic-service ; Inherit values from a template
host_name firewall
service_description Uptime
check_command check_snmp!-C public -o sysUpTime.0
}
define service{
use local-service
host_name www.example.com
service_description Host Alive
check_command check-host-alive
}
hosts
$ cat /etc/nagios3/hosts/www.example.com.cfg
define host{
use generic-host ; Inherit default values from a template
host_name www.example.com ; The name we're giving to this host
alias Some Remote Host ; A longer name associated with the host
address 120.132.14.6 ; IP address of the host
hostgroups all,http-servers ; Host groups this host is associated with
}
define service{
use generic-service ; Inherit default values from a template
host_name www.example.com
service_description HTTP
check_command check_http
}
HTTP狀態
neo@monitor:~$ /usr/lib/nagios/plugins/check_http -H www.example.com -I 172.16.0.8 -s "HTTs" HTTP CRITICAL: HTTP/1.1 404 Not Found - string not found - 336 bytes in 0.001 second response time |time=0.000733s;;;0.000000 size=336B;;;0 neo@monitor:~$ /usr/lib/nagios/plugins/check_http -H www.example.com -I 172.16.0.8 -e '404' HTTP OK: Status line output matched "404" - 336 bytes in 0.001 second response time |time=0.000715s;;;0.000000 size=336B;;;0
$ sudo vim /etc/nagios3/hosts/mysql.cfg
define host{
use generic-host ; Inherit default values from a template
host_name mysql-master.example.com ; The name we're giving to this host
alias Some Remote Host ; A longer name associated with the host
address 172.16.1.6 ; IP address of the host
hostgroups all,mysql-servers ; Host groups this host is associated with
}
define service{
use generic-service ; Inherit default values from a template
host_name mysql-master.example.com
service_description MySQL
check_command check_mysql_database!user!passwd!database
}