nagios监控http(借助脚本)
nagios监控http(借助脚本)
站在用户的角度思考问题,与客户深入沟通,找到武邑网站设计与武邑网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站设计制作、成都网站建设、企业官网、英文网站、手机端网站、网站推广、国际域名空间、雅安服务器托管、企业邮箱。业务覆盖武邑地区。
修改后的脚本如下(需添加指示灯的状态)
# vi httpd.sh
#!/bin/bash
Port=`netstat -ntpl | grep httpd | awk -F[:" "]+ '{print $4}'`
if [ $Port == "80" ];then
echo "OK - http is running"
exit 0
else
echo "CRITICAL - http is down"
/sbin/service httpd restart
exit 2
fi
:wq
注:0 指的是状态灯绿灯,2指的是红灯,黄灯不用 并且宕了之后再次check时就能自动重启
# cp httpd.sh /usr/local/nagios/libexec
# chmod +x /usr/local/nagios/libexec/httpd.sh
# mount /dev/cdrom /media/cdrom
# rpm -ivh sudo-1.6.9pl7-3.el5.i386.rpm
# visudo
#Defaults requiretty (注释掉)
nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/httpd.sh (多个脚本的话设置多行)
:wq
# su - nagios -c 'sudo /usr/local/nagios/libexec/httpd.sh' (看看执行是否成功)
# vi /usr/local/nagios/etc/nrpe.cfg
command[check_http]=/usr/bin/sudo /usr/local/nagios/libexec/httpd.sh
:wq
# killall nrpe
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
# vi /usr/local/nagios/etc/objects/ming.cfg
define service{
use generic-service
host_name ming
service_description http
check_command check_nrpe!check_http
}
:wq
# service nagios restart
分享题目:nagios监控http(借助脚本)
URL链接:http://scyanting.com/article/pddhhh.html