您好,登錄后才能下訂單哦!
使用nagios監(jiān)控被監(jiān)控服務(wù)器上的某一程序,腳本通過查看進(jìn)程狀態(tài)返回狀態(tài)值,并傳送給nagios,來(lái)達(dá)到監(jiān)控目的。nagios每個(gè)插件監(jiān)控會(huì)返回以下狀態(tài)值,我只用到了 0 、1、 2
使用nagios監(jiān)控被監(jiān)控服務(wù)器上的某一程序,腳本通過查看進(jìn)程狀態(tài)返回狀態(tài)值,并傳送給nagios,來(lái)達(dá)到監(jiān)控目的。
nagios每個(gè)插件監(jiān)控會(huì)返回以下狀態(tài)值,我只用到了 0 、1、 2
復(fù)制代碼代碼如下:
#!/bin/bash -x
# Exit values:
# ------------
# 0 OK
# 1 Warning
# 2 Cirital
# 3 Unknown
# Others Unknown
##-------
dfs_process=`ps -ef | grep './dfs client' | grep -v grep`
if [ -z "$dfs_process" ];then
echo "Critical the program of gather is down !!!"
exit 2
fi
process_ppid=`echo $dfs_process|awk '{print $3}'`
process_pid=`echo $dfs_process|awk '{print $2}'`
if [ $process_ppid = 1 ];then
echo 'The process of dfs put back'
exit 1
else
while [ $process_ppid != 1 ]
do
old_process_ppid=$process_ppid
process_ppid=`ps -ef | grep $process_ppid | grep -v $process_pid | grep -v grep | awk '{print $3}'`
process_pid=`ps -ef | grep $old_process_ppid| grep -v $process_pid | grep -v grep|awk '{print $2}'`
done
dfs_pprocess=`ps -ef | grep "$process_pid 1" | grep -v grep`
echo "process of './dfs client' OK ! - Parent process is `echo $dfs_pprocess | awk '{print $8,$9,$10}'`"
exit 0
fi
然后,打開被監(jiān)控端nrpe的配置文件
# vi /usr/local/nagios/etc/nrpe.cfg
添加:
復(fù)制代碼代碼如下:
command[check_dfs]=/usr/local/nagios/libexec/check_dfs.sh
最后,在監(jiān)控端定制監(jiān)控服務(wù)(service.cfg)即可開始監(jiān)控服務(wù)了。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。