Top posting, ok, if you like it...

About sharing how I did it, in attach there is the very dirty nagios probe I
write (cut away the .txt). Messages are in italian, sorry, nobody is perfect
;-) The probe get current thread and request count and busy thread. I use
nagiostat to graph them and forecast my horsepower needs.

The lambda probe uses the standard tomcat-users.xml file, so you can use the
same "manager" user and password you use for the manager interface. Lambda
probe adds some new roles for intermediate security. 

Feel free to query me on problems.

Leandro
 

> -----Messaggio originale-----
> Da: Nix Hanwei [mailto:[EMAIL PROTECTED] 
> Inviato: giovedì 4 settembre 2008 10.28
> A: Tomcat Users List
> Oggetto: Re: R: Monitor and report number of concurrent user
> 
> Hi Leandro,
> 
> That's really cool idea you had used.  Do you mind sharing 
> abit more on how you did it?
> 
> A newbie question here.. I downloaded and expanded probe.war 
> file.  May I know the default user and password?
> 
> Thank you in advance.
> wannabe
> 
> 
> 
> ----- Original Message ----
> From: Leandro Dardini <[EMAIL PROTECTED]>
> To: Tomcat Users List <users@tomcat.apache.org>
> Sent: Thursday, 4 September 2008 15:31:43
> Subject: R: Monitor and report number of concurrent user
> 
> 
> 
> > -----Messaggio originale-----
> > Da: Nix Hanwei [mailto:[EMAIL PROTECTED]
> > Inviato: giovedì 4 settembre 2008 5.19
> > A: Tomcat Users List
> > Oggetto: Monitor and report number of concurrent user
> > 
> > Hi Gurus,
> > 
> > May I know if there's scripts or suggestions for reporting 
> concurrent 
> > user in tomcat?
> > 
> > Thanks in advance,
> > wannabe
> > 
> > 
> 
> The easy and dirty way is to query the manager application 
> and grab the current session, running threads and other vars 
> you are interested in. Be warned the manager application is 
> not so easy to parse.
> The correct path instead is to use JMX. JMX can be used to 
> monitor all aspect of tomcat, like threads, sessions, etc. 
> etc. If you use a jdk >= 1.5 then start adding 
> -Dcom.sun.management.jmxremote to your JAVA_OPTIONS and then 
> look at 
> http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.htm
> l and http://java.sun.com/jmx for details. There is already a 
> nagios probe to get data via jmx 
> http://www.nagiosexchange.org/cgi-bin/page.cgi?g=2338.html;d=1
> 
> I personally use the lambda probe application to monitor my 
> tomcat farm from nagios. It is way too easy to parse.
> 
> Leandro
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org To 
> unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
>       
> ______________________________________________________________________
> Search, browse and book your hotels and flights through Yahoo! Travel.
> http://sg.travel.yahoo.com
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org To 
> unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
#!/bin/sh
#
HOST=$1
PORT=$2
WARNING=$3
CRITICAL=$4
ERRORE="";

if [ $# -ne 4 ];
        then
        echo "Parametri NON corretti!!"
        echo "<host> <port> <warn> <crit>"
        exit -1
fi


if [ $PORT -eq 80 ]; then
    wget -q "$HOST":$PORT/probebinj/status.htm --http-user=manager  
--http-passwd=****** -O /tmp/nagios/tomcat_thread_"$HOST"_$PORT ;
else
    wget -q "$HOST":$PORT/probebinj/status.htm --http-user=manager  
--http-passwd=****** -O /tmp/nagios/tomcat_thread_"$HOST"_$PORT ;
fi

if [ ! -f  /tmp/nagios/tomcat_thread_"$HOST"_$PORT ]; then
        echo "Impossibile scrivere il file"
        exit 2;
fi

ALL_THREADS=`cat /tmp/nagios/tomcat_thread_"$HOST"_$PORT`

if [ "${ALL_THREADS}" == "" ]; then
        echo "Impossibile Connettersi con il Lambda Probe"
        exit 2;
fi

if [ ! -w /tmp/nagios/tomcat_thread_"$HOST"_$PORT ]; then
        echo "Errore Salvataggio File"
        exit 2;
fi

THREAD_COUNT=`grep "Current thread count" 
/tmp/nagios/tomcat_thread_"$HOST"_$PORT | tail -1 |  cut -d\; -f 2` ;
THREAD_BUSY=`grep "Current threads busy" 
/tmp/nagios/tomcat_thread_"$HOST"_$PORT | tail -1 |  cut -d\; -f 2` ;
REQUEST_COUNT=`grep "Request count" /tmp/nagios/tomcat_thread_"$HOST"_$PORT | 
tail -1 |  cut -d\; -f 2` ;

ERRORE=0 ;

if [ $THREAD_BUSY -ge $WARNING ]; then
   ERRORE=1 ;
   if [ $THREAD_BUSY -ge $CRITICAL ]; then
       ERRORE=2 ;
   fi
fi

rm -f /tmp/nagios/tomcat_thread_"$HOST"_$PORT


case $ERRORE in

0)
        echo "OK - Thread Busy: $THREAD_BUSY - Thread Count: $THREAD_COUNT - 
Request count: $REQUEST_COUNT"
        exit 0
;;

1)
        echo "WARNING - Thread Busy: $THREAD_BUSY - Thread Count: $THREAD_COUNT 
- Request count: $REQUEST_COUNT"
        exit 1
;;

2)
        echo "CRITICAL - Thread Busy: $THREAD_BUSY - Thread Count: 
$THREAD_COUNT - Request count: $REQUEST_COUNT"
        exit 2
;;
esac

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to