128 lines
3.4 KiB
Bash
Executable file
128 lines
3.4 KiB
Bash
Executable file
#! /bin/bash
|
|
#
|
|
# Name: zapache
|
|
#
|
|
# Checks Apache activity.
|
|
#
|
|
# Author: Alejandro Michavila
|
|
# Modified for Scoreboard Values: Murat Koc, murat@profelis.com.tr
|
|
# Modified for using also as external script: Murat Koc, murat@profelis.com.tr
|
|
# Modified for outputting usage or ZBX_NOTSUPPORTED: Alejandro Michavila
|
|
#
|
|
# Version: 1.4
|
|
#
|
|
|
|
zapachever="1.4"
|
|
rval=0
|
|
|
|
items[1]=TotalAccesses
|
|
items[2]=TotalKBytes
|
|
items[3]=Uptime
|
|
items[4]=ReqPerSec
|
|
items[5]=BytesPerSec
|
|
items[6]=BytesPerReq
|
|
items[7]=BusyWorkers
|
|
items[8]=IdleWorkers
|
|
items[9]=WaitingForConnection
|
|
items[10]=StartingUp
|
|
items[11]=ReadingRequest
|
|
items[12]=SendingReply
|
|
items[13]=KeepAlive
|
|
items[14]=DNSLookup
|
|
items[15]=ClosingConnection
|
|
items[16]=Logging
|
|
items[17]=GracefullyFinishing
|
|
items[18]=IdleCleanupOfWorker
|
|
items[19]=OpenSlotWithNoCurrentProcess
|
|
|
|
function getval()
|
|
{
|
|
case $1 in
|
|
'TotalAccesses')
|
|
echo "$VAR"|grep "Total Accesses:"|awk '{print $3}'
|
|
return $?;;
|
|
'TotalKBytes')
|
|
echo "$VAR"|grep "Total kBytes:"|awk '{print $3}'
|
|
return $?;;
|
|
'Uptime')
|
|
echo "$VAR"|grep "Uptime:"|awk '{print $2}'
|
|
return $?;;
|
|
'ReqPerSec')
|
|
echo "$VAR"|grep "ReqPerSec:"|awk '{print $2}'
|
|
return $?;;
|
|
'BytesPerSec')
|
|
echo "$VAR"|grep "BytesPerSec:"|awk '{print $2}'
|
|
return $?;;
|
|
'BytesPerReq')
|
|
echo "$VAR"|grep "BytesPerReq:"|awk '{print $2}'
|
|
return $?;;
|
|
'BusyWorkers')
|
|
echo "$VAR"|grep "BusyWorkers:"|awk '{print $2}'
|
|
return $?;;
|
|
'IdleWorkers')
|
|
echo "$VAR"|grep "IdleWorkers:"|awk '{print $2}'
|
|
return $?;;
|
|
'WaitingForConnection')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "_" } ; { print NF-1 }'
|
|
return $?;;
|
|
'StartingUp')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "S" } ; { print NF-1 }'
|
|
return $?;;
|
|
'ReadingRequest')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "R" } ; { print NF-1 }'
|
|
return $?;;
|
|
'SendingReply')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "W" } ; { print NF-1 }'
|
|
return $?;;
|
|
'KeepAlive')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "K" } ; { print NF-1 }'
|
|
return $?;;
|
|
'DNSLookup')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "D" } ; { print NF-1 }'
|
|
return $?;;
|
|
'ClosingConnection')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "C" } ; { print NF-1 }'
|
|
return $?;;
|
|
'Logging')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "L" } ; { print NF-1 }'
|
|
return $?;;
|
|
'GracefullyFinishing')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "G" } ; { print NF-1 }'
|
|
return $?;;
|
|
'IdleCleanupOfWorker')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "I" } ; { print NF-1 }'
|
|
return $?;;
|
|
'OpenSlotWithNoCurrentProcess')
|
|
echo "$VAR"|grep "Scoreboard:"| awk '{print $2}'| awk 'BEGIN { FS = "." } ; { print NF-1 }'
|
|
return $?;;
|
|
esac
|
|
}
|
|
|
|
########
|
|
# Main #
|
|
########
|
|
|
|
if [[ $# == 1 ]];then
|
|
#Trap remote
|
|
VAR=$(wget --quiet -O - http://$1/server-status?auto)
|
|
else
|
|
#Trap localhost
|
|
VAR=$(wget --quiet -O - http://localhost/server-status?auto)
|
|
fi
|
|
|
|
if [[ -z $VAR ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
for itm in "${items[@]}"
|
|
do
|
|
val=$(getval $itm)
|
|
if [ $? -ne 0 ]; then
|
|
echo "- apache.${itm} ZBX_NOTSUPPORTED"
|
|
else
|
|
echo "- apache.${itm} ${val}"
|
|
fi
|
|
done
|
|
|
|
#
|
|
# end zapache
|