How to implement the nagios plug-in for monitoring MFS
Editor to share with you how to achieve the nagios plug-in for monitoring MFS, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
I took down the script and tested it. There seems to be some minor error. I don't know if it is the reason why the system is different.
My test environment is centos 6.586 / 64.
The following is a modified script that I made under the environment of centos 6.586 / 64, and I share it with you.
#! / bin/bash#by cuiyuanrong#QQ:295749093# Nagios return codesSTATE_OK=0STATE_WARNING=1STATE_CRITICAL=2STATE_UNKNOWN=3# Set MFS Path And Warning/CRITICAL ValueMFS_Path= "/ usr/sbin" MFS_Mount_Point= "/ mnt/mfs" WARNING_Value=85CRITICAL_Value=95#Get Master server ProcessMaster () {MFS_PID= `ps-ef | grep mfsmaster | grep ${mfspath} | awk'{print $2} '`if ["${MFS_PID}" = ""] Then echo "ERROR: mfs master does not start" exit $STATE_CRITICALelse echo "OK: mfs master server running OK!" Exit $STATE_OKfi} # Get chunker server ProcessChunker () {MFS_PID= `ps-ef | grep mfschunkserver | grep ${mfspath} | awk'{print $2} '`if ["${MFS_PID}" = "]; then echo" ERROR: mfschunkserver does not start "exit $STATE_CRITICALelse echo" OK: mfs master chunkserver running OK! " Exit $STATE_OKfi} 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 diskused Rate is" ${Disk_used} "exit $STATE_WARNINGelif [${Disk_used}-ge ${criticaldiskused}] Then echo "CRITICAL: mfs disk used Rate is" ${Disk_used} "" exit $STATE_CRITICALelif ["${Disk_used}" = ""]; then echo "CRITICAL: mfs client not mount on" exit $STATE_CRITICALelse echo "OK: MFS client mount on and disk used rate is ${Disk_used}%, Everything is OK!" Exit $STATE_OKfi} # Get metalogger server ProcessMetalogger () {MFS_PID= `ps-ef | grep mfsmetalogger | grep ${mfspath} | awk'{print $2} '`if ["${MFS_PID}" = "]; then echo" ERROR: mfs mfsmetalogger does not start "exit $STATE_CRITICALelse echo" OK: mfs master mfsmetalogger running OK! " Exit $STATE_OKfi} # Functions plugin usageprint_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 parameterwhile [$#-gt 0] do case "$1" in-h |-- help) print_usage exit $STATE_OK ;-M |-- master) mfspath=$ {2Master-"${MFS_Path}"} Master;;-C |-- chunker) mfspath=$ {2Master-"${MFS_Path}"} Chunker -U |-- usedwarning) mountpoint=$ {2 warningdiskused=$-"${MFS_Mount_Point}"} warningdiskused=$ {3 warningdiskused=$-"${WARNING_Value}"} criticaldiskused=$ {4 warningdiskused=$-"${CRITICAL_Value}"} Disk_used -L |-- metalogger) mfspath=$ {2Metalogger-"${MFS_Path}"} Metalogger; *) echo "Unknown argement: $1" exit $STATE_UNKNOWN;; esacshiftdone above is all the content of this article "how to implement the nagios plug-in for monitoring MFS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!