This script monitor Apache
./check_apache
OK – Apache Status Req/s = 0.6 Idel = 4 Busy = 7|Req=0.6;Idle=4;Busy=7
Tested on Ubuntu 12.04 lighthttpd and It works only whe apache mod_status is on.
I also included security on the mod_status access

#!/bin/bash
#Script to get Req/S and Available threads using mod_status
USER="ifgsdf"
PASS="201234124332013"
SERVER="localhost"
PORT="8008"
URL="http://${SERVER}:${PORT}/server-status/?auto"
#echo "Checking $URL"
REQ=`wget -q -O - "$URL" --user="$USER" --password=$PASS |grep ReqPerSec |awk {'print $2'}`
IDLE=`wget -q -O - "$URL" --user="$USER" --password=$PASS |grep IdleWorker |cut -d" " -f2`
BUSY=`wget -q -O - "$URL" --user="$USER" --password=$PASS |grep BusyWorker |cut -d" " -f2`
REQ=`echo $REQ | bc -l | xargs printf "%0.1f" |sed s'/,/./'`
echo "OK - Apache Status Req/s = $REQ Idel = $IDLE Busy = $BUSY|Req=$REQ;Idle=$IDLE;Busy=$BUSY"
Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *