您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
小编给大家分享一下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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。