监控tomcat进程

由其他监控脚本修改而得

#!/bin/bash
#Written by liuer
#This Nagios plugin can be check you tomcat status
USAGE_Method="$(basename $0) [-w|--warning] <thread num> [-c|--critical] <Thread num>"
USAGE_Value="WARNING value must be large than CRITICAL value: `basename $0` $*"
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
if [ $# -lt 4 ];then
echo
echo "Usage: $USAGE_Method"
echo
exit 0
fi
while [ $# -gt 0 ];do
case "$1" in
-w|--warning)
shift
WARNING=$1
;;
-c|--critical)
shift
CRITICAL=$1
;;
esac
shift
done
tomcat_pid=`ps -ef | grep tomcat | grep -v grep  | awk '{print $2}'`
CONNNOW=`lsof -p $tomcat_pid | wc -l`
if [ "$CONNNOW" -ge "$CRITICAL" ]
then
echo "CRITICAL - There must be something wrong with tomcat"
exit 2
fi
if [ "$CONNNOW" -ge "$WARNING" ]
then
echo "WARNING - You shuld see the tomcat to make sure it's ok"
exit 1
fi
if [ "$CONNNOW" -lt "$WARNING" ]
then
echo "OK - $The tomcat seems like running well now"
exit 0
fi

你可能感兴趣的:(tomcat)