updated codepot-mon-httpd

This commit is contained in:
hyung-hwan 2016-01-22 07:51:02 +00:00
parent 5b78418e74
commit ab7156eb67

View File

@ -11,7 +11,8 @@ THRESHOLD=1024
if [ "$1" = "-daemon" ] if [ "$1" = "-daemon" ]
then then
($0 --daemon </dev/null >/dev/null 2>&1 &) & shift
($0 --daemon $@ </dev/null >/dev/null 2>&1 &) &
#($0 --daemon &) & #($0 --daemon &) &
exit 0 exit 0
elif [ "$1" = "--daemon" ] elif [ "$1" = "--daemon" ]
@ -19,24 +20,28 @@ then
DAEMON=1 DAEMON=1
fi fi
[ -n "$2" ] && THRESHOLD="$2"
exit_requested=no exit_requested=no
trap 'exit_requested=yes' SIGINT SIGHUP SIGTERM trap 'exit_requested=yes' SIGINT SIGHUP SIGTERM
[ "${DAEMON}" = "1" ] && logger -t "$0" "Started" [ "${DAEMON}" = "1" ] && logger -t "$0" "Started (THRESHOLD=$THRESHOLD)"
while [ "${exit_requested}" = "no" ] while [ "${exit_requested}" = "no" ]
do do
sleep 5 sleep 5
ps -ylC httpd | awk -vdaemon=$DAEMON -v"self=$0" -vthreshold=$THRESHOLD ' ps -ylC httpd | awk -vdaemon=$DAEMON -v"self=$0" -vthreshold=$THRESHOLD '
{ /httpd/ {
x += $8; x += $8;
y += 1; y += 1;
} }
END { END {
if (y > 0)
{
MB = x / 1024; MB = x / 1024;
AVGMB = x / ((y - 1) * 1024); AVGMB = x / (y * 1024);
if (daemon <= 0) if (daemon <= 0)
{ {
@ -57,6 +62,7 @@ END {
} }
} }
} }
}
' '
done done