CentOS + Nagios 监控Web服务器
October 23, 2010 – 12:23 am测试环境
CentOS 5.5 x86_64,安装开发工具和开发库;
关闭selinux;
服务端IP地址:192.168.90.187,hostname:vps1;
客户端IP地址:192.168.90.237,hostname:vps2,由apache提供web服务。
关闭selinux;
服务端IP地址:192.168.90.187,hostname:vps1;
客户端IP地址:192.168.90.237,hostname:vps2,由apache提供web服务。
vi /usr/local/nagios/etc/lan_objects/hosts.cfg
# http 服务
define host{
use generic-host
host_name vps2_apache
alias Apache Web Server
address 192.168.90.237
check_command check-host-alive
max_check_attempts 10
check_period 24x7
notification_interval 120
notification_period 24x7
notification_options d,r
contact_groups admins
}
define hostgroup{
hostgroup_name apache_servers
alias Web Servers
members vps2
}
define host{
use generic-host
host_name vps2_apache
alias Apache Web Server
address 192.168.90.237
check_command check-host-alive
max_check_attempts 10
check_period 24x7
notification_interval 120
notification_period 24x7
notification_options d,r
contact_groups admins
}
define hostgroup{
hostgroup_name apache_servers
alias Web Servers
members vps2
}
vi /usr/local/nagios/etc/lan_objects/services.cfg
# 监控HTTP服务
define service{
use generic-service
host_name vps2
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command check_http
}
define service{
use generic-service
host_name vps2
service_description HTTP
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command check_http
}
运行语法检查器
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
重启nagios
/etc/init.d/nagios restart
继续查看Service Detail即可看到效果。