您好,登錄后才能下訂單哦!
小編給大家分享一下nagios中mfs如何監(jiān)控腳本,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
最近一直在測(cè)試mfs,最后在線上測(cè)試完畢后,開始整理監(jiān)控mfs,
mfs監(jiān)控指標(biāo)
監(jiān)聽端口
監(jiān)聽進(jìn)程
監(jiān)聽vip
監(jiān)聽讀寫
現(xiàn)在附監(jiān)控進(jìn)程是否存活shell腳本,僅供參考
root@loocha4:/usr/local/nagios/libexec/New# cat check_mfs.sh #!/bin/bash # =========================================================================================================== # # MFS status check plugins for nagios # # Written by : caimengzhi # Release : 1.0 # Create Date : 2017-01-12 # Description : Nagios plugins (script) to check MFS status # # =========================================================================================================== # Nagios return codes STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 status=0 #Get Master server Process Master(){ MFS_PID=$(ps -ef | grep -v grep | grep mfsmaster | wc -l) if [ ${MFS_PID} -eq 0 ];then echo "ERROR : mfs master does not start" exit $STATE_CRITICAL else echo "OK : mfs master server running OK!" exit $STATE_OK fi } #Get chunker server Process Chunker(){ MFS_PID=$(ps -ef | grep -v grep | grep mfschunkserver | wc -l) if [ ${MFS_PID} -eq 0 ];then echo "ERROR : mfs chunkserver does not start" exit $STATE_CRITICAL else echo "OK : mfs master chunkserver running OK!" exit $STATE_OK fi } Disk_used(){ Disk_used=`df -h | grep ${mountpoint} |awk '{print $4}'` if [ ${Disk_used%/%} -ge ${warningdiskused} -a ${Disk_used%/%} -lt ${criticaldiskused} ];then echo "Waring :mfs disk used Rate is "${Disk_used}"" exit $STATE_WARNING elif [ ${Disk_used%/%} -ge ${criticaldiskused} ];then echo "CRITICAL :mfs disk used Rate is "${Disk_used}"" exit $STATE_CRITICAL elif [ "${Disk_used%/%}" = "" ];then echo "CRITICAL :mfs client not mount on" exit $STATE_CRITICAL else echo "OK : MFS client mount on and disk used rate is "${Disk_used}" , Everything is OK!" exit $STATE_OK fi } #Get metalogger server Process Metalogger(){ MFS_PID=$(ps -ef | grep -v grep | grep mfsmetalogger | wc -l) if [ ${MFS_PID} -eq 0 ];then echo "ERROR : mfs mfsmetalogger does not start" exit $STATE_CRITICAL else echo "OK : mfs master mfsmetalogger running OK!" exit $STATE_OK fi } # Functions plugin usage print_usage() { echo "" echo " -M MFS master server status " echo " -C MFS chunker server status " echo " -U MFS client disk used Rate " echo " -L MFS metalogger server status " echo " -h Show this page " echo "" echo " Usage1 : sh check_mfs.sh -M mfsmasterpath" echo " ex : sh check_mfs.sh -M /usr/sbin/mfs" echo " Usage2 : sh check_mfs.sh -C mfschunkpath" echo " ex : sh check_mfs.sh -C /usr/sbin/mfs" echo " Usage3 : sh check_mfs.sh -U mountpoint warningrate criticalrate" echo " ex : sh check_mfs.sh -U /mnt/mfs 60 80" echo " Usage4 : sh check_mfs.sh -L mfsmetaloggerpath" echo " ex : sh check_mfs.sh -L /usr/sbin/mfs" echo " ex : sh check_mfs.sh -h" echo "" exit 0 } if [ $# -ne 1 ]; then echo "Pls input sh $0 -h and check." print_usage exit 1; fi # Parse parameter while [ $# -gt 0 ] do case "$1" in -H | -h | --help) print_usage exit $STATE_OK ;; -M | -m | --master) Master ;; -C | -c | --chunker) Chunker ;; -U | -u | --usedwarning) mountpoint=${2:-"/mnt/mfs"} warningdiskused=${3:-"75"} criticaldiskused=${4:-"85"} Disk_used ;; -L | -l | --metalogger) Metalogger ;; *) echo "Unknown argement: $1" print_usage exit $STATE_UNKNOWN ;; esac shift done exit 0
以下是測(cè)試效果
root@loocha4:/usr/local/nagios/libexec/New# ps aux|grep mfs root 1148 0.0 0.0 8112 936 pts/0 S+ 13:29 0:00 grep --color=auto mfs mfs 6021 1.2 0.3 455572 204124 ? S<l 2016 246:19 /usr/sbin/mfschunkserver start mfs 6039 0.1 0.0 17748 1516 ? S< 2016 30:49 /usr/sbin/mfsmetalogger start mfs 23784 0.3 0.7 534044 501192 ? S< 2016 91:43 /usr/sbin/mfsmaster start root@loocha4:/usr/local/nagios/libexec/New# ./check_mfs.sh -m OK : mfs master server running OK! root@loocha4:/usr/local/nagios/libexec/New# ./check_mfs.sh -M OK : mfs master server running OK! root@loocha4:/usr/local/nagios/libexec/New# ./check_mfs.sh -l OK : mfs master mfsmetalogger running OK! root@loocha4:/usr/local/nagios/libexec/New# ./check_mfs.sh -L OK : mfs master mfsmetalogger running OK! root@loocha4:/usr/local/nagios/libexec/New# ./check_mfs.sh -c OK : mfs master chunkserver running OK! root@loocha4:/usr/local/nagios/libexec/New# ./check_mfs.sh -C OK : mfs master chunkserver running OK! root@loocha4:/usr/local/nagios/libexec/New# ./check_mfs.sh Pls input sh ./check_mfs.sh -h and check. ------------------------------------------------------------------ -M MFS master server status -C MFS chunker server status -U MFS client disk used Rate -L MFS metalogger server status -h Show this page Usage1 : sh check_mfs.sh -M mfsmasterpath ex : sh check_mfs.sh -M /usr/sbin/mfs Usage2 : sh check_mfs.sh -C mfschunkpath ex : sh check_mfs.sh -C /usr/sbin/mfs Usage3 : sh check_mfs.sh -U mountpoint warningrate criticalrate ex : sh check_mfs.sh -U /mnt/mfs 60 80 Usage4 : sh check_mfs.sh -L mfsmetaloggerpath ex : sh check_mfs.sh -L /usr/sbin/mfs ex : sh check_mfs.sh -h ------------------------------------------------------------------
以上是“nagios中mfs如何監(jiān)控腳本”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(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)容。