您好,登錄后才能下訂單哦!
小編給大家分享一下nagios中mfs如何監控腳本,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
最近一直在測試mfs,最后在線上測試完畢后,開始整理監控mfs,
mfs監控指標
監聽端口
監聽進程
監聽vip
監聽讀寫
現在附監控進程是否存活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
以下是測試效果
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如何監控腳本”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。