2012-02-18 00:02:05 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#################################################################
|
|
|
|
#
|
|
|
|
# Script to monitor apc usage
|
|
|
|
#
|
|
|
|
#################################################################
|
|
|
|
#
|
|
|
|
# Parameters understood: config, autoconf and suggest
|
|
|
|
#
|
|
|
|
#################################################################
|
|
|
|
#
|
|
|
|
# Configuration section
|
2012-07-30 17:13:53 +02:00
|
|
|
#
|
|
|
|
# Configuration example
|
|
|
|
#
|
|
|
|
# [php_apc_*]
|
|
|
|
# user root
|
|
|
|
# env.URL http://localhost/php_apc.php # URL to fetch APC status
|
2012-02-18 00:02:05 +01:00
|
|
|
#
|
2012-07-30 17:13:53 +02:00
|
|
|
# (php_apc.php file included in package)
|
2012-02-18 00:02:05 +01:00
|
|
|
#
|
|
|
|
#################################################################
|
|
|
|
#
|
|
|
|
# Changelog:
|
|
|
|
# - First Release, Enjoy.
|
|
|
|
#
|
|
|
|
#################################################################
|
|
|
|
#################################################################
|
|
|
|
# Settigs required for autoconf
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf suggest
|
|
|
|
|
2012-07-30 17:13:53 +02:00
|
|
|
# URL to the script to check APC status (defaults to
|
|
|
|
# 'http://localhost/php_apc.php' if not configured)
|
|
|
|
URL=${URL:-'http://localhost/php_apc.php'}
|
|
|
|
|
2012-02-18 00:02:05 +01:00
|
|
|
WGET=`which wget`;
|
|
|
|
WGET_FLAGS="-Yoff"; # refer to wget manual, you may set extra parameters like disable proxy
|
|
|
|
act=`basename $0 | sed 's/^php_apc_//g'`
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
[ -z "$URL" ] && echo "no (edit URL config in header file !)" && exit 1
|
|
|
|
[ -n "$URL" ] && echo "yes" && exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "suggest" ]; then
|
|
|
|
echo "memory"
|
|
|
|
echo "hits"
|
|
|
|
echo "percents"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ] && [ "$act" = "memory" ]; then
|
|
|
|
|
|
|
|
cat <<'EOM'
|
|
|
|
graph_title APC Memory usage
|
|
|
|
graph_args -l 0 --base 1024
|
|
|
|
graph_vlabel Memory usage
|
2017-02-21 18:24:41 +01:00
|
|
|
graph_category memory
|
2012-02-18 00:02:05 +01:00
|
|
|
graph_order mem_used mem_avail
|
|
|
|
graph_total Total
|
|
|
|
mem_avail.label Memory available
|
|
|
|
mem_avail.draw STACK
|
|
|
|
mem_avail.min 0
|
2015-04-15 18:14:52 +02:00
|
|
|
mem_used.label Memory used
|
2012-02-18 00:02:05 +01:00
|
|
|
mem_used.draw AREA
|
|
|
|
mem_used.min 0
|
|
|
|
EOM
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ] && [ "$act" = "hits" ]; then
|
|
|
|
|
|
|
|
cat <<'EOM'
|
|
|
|
graph_title APC Hits
|
|
|
|
graph_args -l 0
|
|
|
|
graph_vlabel Cache hits
|
2017-02-21 22:15:07 +01:00
|
|
|
graph_category memory
|
2012-02-18 00:02:05 +01:00
|
|
|
graph_total Total
|
2015-04-15 18:14:52 +02:00
|
|
|
num_misses.label Misses
|
2012-02-18 00:02:05 +01:00
|
|
|
num_misses.draw AREA
|
|
|
|
num_misses.min 0
|
|
|
|
num_hits.label Hits
|
|
|
|
num_hits.draw STACK
|
|
|
|
num_hits.min 0
|
|
|
|
EOM
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ] && [ "$act" = "percents" ]; then
|
|
|
|
|
|
|
|
cat <<'EOM'
|
|
|
|
graph_title APC Percents
|
|
|
|
graph_args -l 0 --upper-limit 100
|
2015-04-15 18:29:09 +02:00
|
|
|
graph_scale no
|
2012-02-18 00:02:05 +01:00
|
|
|
graph_vlabel Cache Percents %
|
2017-02-21 22:15:07 +01:00
|
|
|
graph_category memory
|
2015-04-15 18:14:52 +02:00
|
|
|
hits.label Hits
|
2012-02-18 00:02:05 +01:00
|
|
|
hits.draw AREA
|
|
|
|
hits.min 0
|
2015-04-15 18:14:52 +02:00
|
|
|
misses.label Misses
|
2012-02-18 00:02:05 +01:00
|
|
|
misses.draw STACK
|
|
|
|
misses.min 0
|
|
|
|
misses.warning 50
|
|
|
|
memory.label Memory
|
|
|
|
memory.draw LINE
|
|
|
|
memory.warning 95
|
|
|
|
memory.critical 98
|
|
|
|
EOM
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#################################################################
|
|
|
|
# run the sript
|
|
|
|
|
|
|
|
[ -x $WGET ] && $WGET -q $WGET_FLAGS "$URL?act=$act" -O - && exit 0
|
|
|
|
|
|
|
|
exit 1
|