nagios的自动事务处理测试.docVIP

  • 3
  • 0
  • 约4.65千字
  • 约 7页
  • 2018-01-04 发布于河南
  • 举报
nagios的自动事务处理测试

今天对nagios的自动事务处理做了测试,过程很艰辛。不过还好最后搞定了。现在分享一下: 一、客户端的配置 A、编写自动事务处理的脚本,此处测试的是httpd进程。也就是检测到http进程不在了会触发自动重启服务脚本。 脚本名称:http_handler,存放路径:/usr/local/nagios/libexec/http_handler 脚本属性: 脚本内容: #!/bin/sh # eventhander to restart httpd date=`date` #test the script #echo $date /tmp/mylog #echo $1,$2,$3 /tmp/mylog case $1 in OK) ;; WARNING) ;; UNKNOWN) ;; CRITICAL) case $2 in SOFT) case $3 in 3) #echo -en Restarting httpd service (3rd soft critical state)...\n echo OK- httpd had restart! #for test use /tmp/mylog for print the info for script run!! /usr/bin/sudo /etc/init.d/httpd restart /dev/null 2 1 # /usr/bin/sudo /etc/init.d/httpd restart /tmp/mylog 21 echo $date - restart BLAH - SOFT /tmp/eventhandlers ;; esac ;; HARD) case $3 in 1) echo ok-httpd had restart! #echo -en Restarting httpd service...\n # Call the init script to restart the NRPE server echo $date - restart BLAH - HARD /tmp/eventhandlers #for test use /tmp/mylog for print the info for script run!! /usr/bin/sudo /etc/init.d/httpd restart /dev/null 2 1 # /usr/bin/sudo /etc/init.d/httpd restart /tmp/mylog 21 ;; esac ;; esac ;; esac exit 0 脚本说明: 此脚本接受服务器端发送来的event_handler命令,带有三个参数,分别是: $SERVICESTATE$ 检测服务的状态,有“ok”,“Warning”,“Unknow” ,“CRITICAL” $SERVICESTATETYPE$ 检测是软还是硬 也就是“SOFT”、“HARD” $SERVICEATTEMPT$ 检测的次数 以上脚本的意思是: 1、检测http服务处于CRITICAL SOFT 3 (http服务不可用、轻微、3次)会触发脚本重启httpd服务。 2、检测http服务处于CRITICAL

文档评论(0)

1亿VIP精品文档

相关文档