#!/bin/bash
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Pound Requests per Second'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel number of requests'
echo 'graph_category Pound'
echo 'graph_info This graph shows the number of Pound Requests per second.'
echo 'pound.label Requests Per Second'
echo 'pound.draw LINE2'
echo 'pound.info The number of Pound requests per second.'
#echo 'poundavg.label Avg Time for Requests (Sec)'
#echo 'poundavg.draw LINE2'
#echo 'poundavg.info Average Request Time (Sec).'
exit 0
fi
# START CODE
function cleanup {
unset FILE
unset TMPFILE
unset TMPFILE2
unset TMPFILE3
unset LOGFILE
unset MONTH
unset DAY
unset HOUR
unset MINUTE
unset SECOND
unset LASTMESSAGE_TOTAL
unset LASTLINE
unset ORIGLINE
unset LASTMESSAGE
unset LASTMESSAGES
unset CHECK
unset FOUND
unset LINES
unset RANGE
unset RPS
unset TOTAL
unset COUNTSEC
unset COUNTMIN
unset COUNTHOUR
unset COUNT
unset LAST
unset FINISHED
}
cleanup
FILE="/var/log/syslog"
TMPFILE="/dev/shm/munin_pound"
TMPFILE2="/dev/shm/munin_pound2"
TMPFILE3="/dev/shm/munin_pound3"
LOGFILE="/root/munin_pound.log"
rm $TMPFILE $TMPFILE2 $TMPFILE3 &> /dev/null
touch $TMPFILE $TMPFILE2 $TMPFILE3
date >> $LOGFILE
MONTH=`date +%b --date="5 minutes ago"`
DAY=`date +%d --date="5 minutes ago" | sed s/^0//g`
HOUR=`date +%H --date="5 minutes ago"`
MINUTE=`date +%M --date="5 minutes ago"`
SECOND=`date +%S --date="5 minutes ago"`
LASTMESSAGE_TOTAL=0
COUNT=0
function last_message {
LASTLINE="`tail -n1 $TMPFILE`"
ORIGLINE=`grep -n -e "$LASTLINE" $FILE | head -n1 | cut -d: -f1`
tail -n "+$ORIGLINE" $FILE > $TMPFILE2
LASTMESSAGES=`grep -n -e "last message repeated [0-9]\+ times" $TMPFILE2 | cut -d: -f1`
echo $LASTMESSAGES >> $TMPFILE3
echo starting >> $TMPFILE3
for LASTMESSAGE in $LASTMESSAGES; do
LASTMESSAGE=`echo $LASTMESSAGE - 1 | bc`
CHECK=`perl -nwe "$LASTMESSAGE..$LASTMESSAGE and print" $TMPFILE2`
FOUND=`echo $CHECK | grep -c -e "pound: [1-9]\+."`
if [ $FOUND -eq 1 ]; then
FOUND=0
LASTMESSAGE=`echo $LASTMESSAGE + 1 | bc`
CHECK=`perl -nwe "$LASTMESSAGE..$LASTMESSAGE and print" $TMPFILE2`
FOUND=`echo $CHECK | sed s/".*last message repeated"//g | sed s/"[a-zA-Z ]"//g`
LASTMESSAGE_TOTAL=`echo $LASTMESSAGE_TOTAL + $FOUND | bc`
fi
done
}
function finish {
if [ $FINISHED -eq 1 ]; then
last_message
LINES=`cat $TMPFILE | wc -l`
LINES=`echo $LINES + $LASTMESSAGE_TOTAL | bc`
#cat $TMPFILE | grep -o -e "[0-9]\+\.[0-9]\+\ sec" | cut -d\ -f1 > $TMPFILE2
#TIME=`xargs echo < $TMPFILE2 | sed s/\ /\+/g | bc`
#echo $TIME $LINES
#AVGTIME=`echo "scale=3; $LINES / $TIME" | bc`
#echo poundavg.value $AVGTIME
RANGE=`echo "60 * 5" | bc`
RPS=`echo "scale=2; $LINES / $RANGE" | bc`
echo "pound.value $RPS"
cleanup
exit
fi
}
function cut_old {
TOTAL=`cat $TMPFILE | wc -l`
if [ ${LAST:=0} -lt $TOTAL ]; then
head -n $LAST $TMPFILE > $TMPFILE2
rm $TMPFILE && mv $TMPFILE2 $TMPFILE
unset LAST
fi
finish
}
function roll_time {
SECOND=`echo $SECOND | sed s/^0//g`
MINUTE=`echo $MINUTE | sed s/^0//g`
HOUR=`echo $HOUR | sed s/^0//g`
if [ $SECOND -eq 60 ]; then
SECOND=0
let "MINUTE += 1"
fi
if [ $MINUTE -eq 60 ]; then
MINUTE=0
let "HOUR += 1"
fi
if [ $HOUR -eq 24 ]; then
HOUR=0
let "DAY += 1"
fi
COUNTSEC=`echo $SECOND | wc -c`
COUNTMIN=`echo $MINUTE | wc -c`
COUNTHOUR=`echo $HOUR | wc -c`
if [ $COUNTSEC -eq 2 ]; then
SECOND=`echo $SECOND | sed s/^/0/g`
fi
if [ $COUNTMIN -eq 2 ]; then
MINUTE=`echo $MINUTE | sed s/^/0/g`
fi
if [ $COUNTHOUR -eq 2 ]; then
HOUR=`echo $HOUR | sed s/^/0/g`
fi
}
tac $FILE | grep -e "pound: [1-9]\+." > $TMPFILE
LAST=`nice -n19 grep -n -e "^$MONTH[ ]\+$DAY[ ]\+" $TMPFILE | tail -n1 | cut -d: -f1`
FINISHED=`cat $TMPFILE | wc -l | grep -c -e "^0$"`
cut_old
LAST=`nice -n19 grep -n -e "^$MONTH[ ]\+$DAY[ ]\+$HOUR" $TMPFILE | tail -n1 | cut -d: -f1`
FINISHED=`cat $TMPFILE | wc -l | grep -c -e "^0$"`
cut_old
LAST=`nice -n19 grep -n -e "^$MONTH[ ]\+$DAY[ ]\+$HOUR:$MINUTE" $TMPFILE | tail -n1 | cut -d: -f1`
FINISHED=`cat $TMPFILE | wc -l | grep -c -e "^0$"`
cut_old
# FIX 3 to 300
while [ ${LAST:=0} -eq 0 ] && [ ${COUNT:=0} -lt 300 ]; do
LAST=`nice -n19 grep -n -e "^$MONTH[ ]\+$DAY[ ]\+$HOUR:$MINUTE:$SECOND" $TMPFILE | tail -n1 | cut -d: -f1`
SECOND=`echo $SECOND + 1 | bc`
COUNT=`echo $COUNT + 1 | bc`
roll_time
done
echo $COUNT >> $LOGFILE
if [ $COUNT -eq 300 ]; then
echo "pound.value 0"
cleanup
exit
fi
FINISHED=1
cut_old
Hello,
is there a possibility to get the requests per second generated from pound? I've deactivated logging on my backendservers, so I can't get these value from them ...
With poundctl I can only monitor the active sessions, but not the active requests/minute - right? The logfile grows to fast to get therefrom any infos with grep, wc or such things :(
I'm very interested in any suggestions.
Thanks in advance,
Robert
--
To unsubscribe send an email with subject unsubscribe to pound@apsis.ch.
Please contact roseg@apsis.ch for questions.
This e-mail message has been scanned and cleared by MailMarshal - www.marshalsoftware.com and Sophos Anti-virus