首页 > 代码库 > mfs 监控脚本
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 ------------------------------------------------------------------
mfs 监控脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。