小編給大家分享一下如何實(shí)現(xiàn)監(jiān)控MFS的nagios插件,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的文昌網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
我把腳本拿下來(lái)測(cè)試了一下,貌似有些小錯(cuò)誤,不知道是不是系統(tǒng)不一樣的原因。
我的測(cè)試環(huán)境是centos 6.5 86_64。
以下是我在centos 6.5 86_64環(huán)境下做了修改的腳本,分享給大家。
#!/bin/bash #by cuiyuanrong #QQ:295749093 # Nagios return codes STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 STATE_UNKNOWN=3 # Set MFS Path And Warning/CRITICAL Value MFS_Path="/usr/sbin" MFS_Mount_Point="/mnt/mfs" WARNING_Value=85 CRITICAL_Value=95 #Get Master server Process Master(){ MFS_PID=`ps -ef | grep mfsmaster | grep ${mfspath} | awk '{print $2}'` if [ "${MFS_PID}" = "" ];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 mfschunkserver | grep ${mfspath} | awk '{print $2}'` if [ "${MFS_PID}" = "" ];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 $5}' | awk -F% '{print $1}'` 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 mfsmetalogger | grep ${mfspath} | awk '{print $2}'` if [ "${MFS_PID}" = "" ];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() { Program_name=$(basename $0) 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 : ${Program_name} -M mfsmasterpath" echo " ex : ${Program_name} -M ${MFS_Path}" echo " Usage2 : ${Program_name} -C mfschunkpath" echo " ex : ${Program_name} -C ${MFS_Path}" echo " Usage3 : ${Program_name} -U mountpoint warningrate criticalrate" echo " ex : ${Program_name} -U ${MFS_Mount_Point} 60 80" echo " Usage4 : ${Program_name} -L mfsmetaloggerpath" echo " ex : ${Program_name} -L ${MFS_Path}" echo " ex : ${Program_name} -h" echo "" exit 0 } # Parse parameter while [ $# -gt 0 ] do case "$1" in -h | --help) print_usage exit $STATE_OK ;; -M | --master) mfspath=${2:-"${MFS_Path}"} Master ;; -C | --chunker) mfspath=${2:-"${MFS_Path}"} Chunker ;; -U | --usedwarning) mountpoint=${2:-"${MFS_Mount_Point}"} warningdiskused=${3:-"${WARNING_Value}"} criticaldiskused=${4:-"${CRITICAL_Value}"} Disk_used ;; -L | --metalogger) mfspath=${2:-"${MFS_Path}"} Metalogger ;; *) echo "Unknown argement: $1" exit $STATE_UNKNOWN ;; esac shift done
以上是“如何實(shí)現(xiàn)監(jiān)控MFS的nagios插件”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!