Linux Nagios 监控jboos sh

                Nagios 监控jboos的脚本

 

#!/bin/bash
path=/usr/local/nagios/libexec

logfile=/var/log/jboosmoniter.log

date=`(date +%D--%T)`

ps -eo pid,tty,user,comm,stime,etime | more |grep java|sed 's/://g'>$path/pid.txt

result=`( awk '/master/ {print $6}' $path/pid.txt |sed -e 's/://g' -e 's/-//g')`


$path/check_http -H 127.0.0.1 -p 8080 -u /registration/index.jsp >$path/a.txt

a=`(awk '{print $4}' $path/a.txt)`

echo $a >$path/states.txt

valuse=`(cat $path/states.txt)`

awk '/refused/ {print $2}' $path/a.txt>$path/b.txt

f=`(cat $path/b.txt)`

q=refused

level=1000


if [ $valuse != 200 ]

  then
     if  (( "10#$result" > "$level" ))

      then
            killall -9 java;/etc/init.d/jboss start;echo "the jboos server have reboot on $date">>$logfile

    fi
fi
if [ "$f" = "$q" ]

         then
       killall -9 java;/etc/init.d/jboss start;echo "the jboos server have dead but it start on $date">>$logfile

fi

 

你可能感兴趣的:(linux,jsp,jboss,bash,nagios)