您好,登錄后才能下訂單哦!
nagios監(jiān)控http(借助腳本)
修改后的腳本如下(需添加指示燈的狀態(tài))
# 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 指的是狀態(tài)燈綠燈,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' (看看執(zhí)行是否成功)
# 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
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。