Interesting question, but I'm quite sure you can't.
A workaround may be killing of some apache-threads and make sure you are the first one to connect to the newly spawned processes to show the apache status.
Edit: yes, let's play with bash
the following works by pulling the scoreboard of your Apache server-status page and letting you define when to react.
Use the _f_custom() function for that. I've built in two examples:
- If there are more than 150 processes in Sending Reply mode, you will receive an email
- If there are less then 20 open slots, also send an email.
`
#!/bin/bash
_sleep="5"
_f_getfullstatus() {
curl $_uri 2> /dev/null
}
_f_mailto() {
( echo -e "To:$1\nFrom:$1\nSubject:${2}:\n\n${3} ${4}" ; _f_getfullstatus ) | sendmail -t
}
_f_custom() {
case "$1" in
_)
;;
S)
;;
W)
if [[ $2 -gt 150 ]] ; then _f_mailto $_email "Houson, we've got a problem" "Currently there are $2 processes in "sending reply" mode" ; fi
;;
K)
;;
D)
;;
L)
;;
G)
;;
I)
;;
.)
if [[ $2 -lt 20 ]] ; then _f_mailto $_email "Running out of open slots" "there are only $2 available atm" ; fi
;;
esac
}
_f_count() {
for _status in _ S R W K D C L G I \.
do
_counter=$(echo $_auto_output | sed "s/[^$_status]//g" | wc -m)
if [[ $_verbose == "yes" ]] ; then
echo -n "Status of key ${_status}:"
echo $_counter
fi
_f_custom $_status $_counter
done
}
while [[ $# > 0 ]] ; do
_opt="$1"
case $_opt in
-u)
shift
_uri="$1"
;;
-m)
shift
_email="$1"
;;
-s)
shift
_sleep="$1"
;;
-D)
_daemon="yes"
;;
-v)
_verbose="yes"
;;
esac
shift
done
_auto_output=$(curl ${_uri}?auto 2> /dev/null | tail -1 | sed 's/Scoreboard: //g')
if [[ $_daemon == "yes" ]] ; then
while true ; do
_f_count
sleep $_sleep
done
else
_f_count
fi
This needs sendmail
and curl
in $PATH
as --help is not implemented:
-u: URI to server-status page
-m: sets a emailaddress to send your errors to
-v: let it run verbosly
-D: let it run in w while true loop (daemonize)
-s: interval in seconds between status requests