mfs 监控脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mfs 监控脚本相关的知识,希望对你有一定的参考价值。
最近一直在测试mfs,最后在线上测试完毕后,开始整理监控mfs,
mfs监控指标
监听端口
监听进程
监听vip
监听读写
现在附监控进程是否存活shell脚本,仅供参考
[email protected]:/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
以下是测试效果
[email protected]:/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 [email protected]:/usr/local/nagios/libexec/New# ./check_mfs.sh -m OK : mfs master server running OK! [email protected]:/usr/local/nagios/libexec/New# ./check_mfs.sh -M OK : mfs master server running OK! [email protected]:/usr/local/nagios/libexec/New# ./check_mfs.sh -l OK : mfs master mfsmetalogger running OK! [email protected]:/usr/local/nagios/libexec/New# ./check_mfs.sh -L OK : mfs master mfsmetalogger running OK! [email protected]:/usr/local/nagios/libexec/New# ./check_mfs.sh -c OK : mfs master chunkserver running OK! [email protected]:/usr/local/nagios/libexec/New# ./check_mfs.sh -C OK : mfs master chunkserver running OK! [email protected]:/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 ------------------------------------------------------------------
以上是关于mfs 监控脚本的主要内容,如果未能解决你的问题,请参考以下文章