您好,登錄后才能下訂單哦!
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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。