CentOS + Nagios 监控服务器SSHD
October 22, 2010 – 8:19 pm测试环境:
CentOS 5.5 x86_64,安装开发工具和开发库;
关闭selinux;
服务端IP地址:192.168.90.187,hostname:vps1;
客户端IP地址:192.168.90.237,hostname:vps2。
关闭selinux;
服务端IP地址:192.168.90.187,hostname:vps1;
客户端IP地址:192.168.90.237,hostname:vps2。
接上篇安装配置Nagios监控服务器基本功能,这次我们使用nagios监控sshd。修改配置文件:
vi /usr/local/nagios/etc/lan_objects/commands.cfg
# 检查SSH配置
define command{
command_name check_ssh
command_line $USER1$/check_ssh -H $HOSTADDRESS$
}
define command{
command_name check_ssh
command_line $USER1$/check_ssh -H $HOSTADDRESS$
}
vi /usr/local/nagios/etc/lan_objects/hosts.cfg
# ssh 服务器
define host{
use generic-host
host_name vps2
alias vps2
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 misc_servers
alias Servers
members vps2
}
define host{
use generic-host
host_name vps2
alias vps2
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 misc_servers
alias Servers
members vps2
}
vi /usr/local/nagios/etc/lan_objects/services.cfg
# 定义监控SSH
define service{
use generic-service
host_name vps2
service_description SSH
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_ssh
}
define service{
use generic-service
host_name vps2
service_description SSH
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_ssh
}
运行nagios语法检查
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
重新启动nagios
/etc/init.d/nagios restart
现在访问http://192.168.90.187/nagios,点击左侧的“Service Detail”,过几分钟看看是不是显示监控信息了,如图: