2013-06-24 14:11:49 +02:00
|
|
|
#!/bin/sh
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Munin plugin to monitor Zend OPCache <http://php.net/manual/en/book.opcache.php>
|
|
|
|
# By Daniel Lo Nigro <http://dan.cx/>
|
|
|
|
#
|
|
|
|
# Installation:
|
|
|
|
# 1. Copy php_opcache.php file onto server and verify you can hit it in a browser
|
|
|
|
# 2. Add to Munin config:
|
|
|
|
# [php_opcache]
|
|
|
|
# env.URL http://example/php_opcache.php
|
|
|
|
###############################################################################
|
|
|
|
# Settigs required for autoconf
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf suggest
|
|
|
|
|
|
|
|
URL=${URL:-'http://localhost/php_opcache.php'}
|
|
|
|
|
|
|
|
WGET=`which wget`;
|
|
|
|
WGET_FLAGS="-Yoff"; # refer to wget manual, you may set extra parameters like disable proxy
|
|
|
|
act=memory
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
2018-09-16 05:03:47 +02:00
|
|
|
if [ -z "$URL" ]; then
|
|
|
|
echo "no (missing URL config in header file)"
|
|
|
|
else
|
|
|
|
echo "yes"
|
|
|
|
fi
|
|
|
|
exit 0
|
2013-06-24 14:11:49 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "suggest" ]; then
|
|
|
|
echo "memory"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ] && [ "$act" = "memory" ]; then
|
|
|
|
|
|
|
|
cat <<'EOM'
|
|
|
|
graph_title OPCache Memory usage
|
|
|
|
graph_args -l 0 --base 1024
|
|
|
|
graph_vlabel Memory usage
|
2017-02-21 18:24:41 +01:00
|
|
|
graph_category memory
|
2015-03-26 19:03:11 +01:00
|
|
|
graph_order mem_used mem_free mem_wasted
|
2013-06-24 14:11:49 +02:00
|
|
|
graph_total Total
|
|
|
|
mem_free.label Memory Free
|
|
|
|
mem_free.draw STACK
|
|
|
|
mem_free.min 0
|
|
|
|
mem_used.label Memory Used
|
|
|
|
mem_used.draw AREA
|
|
|
|
mem_used.min 0
|
2015-03-26 19:03:11 +01:00
|
|
|
mem_wasted.label Memory Wasted
|
|
|
|
mem_wasted.draw STACK
|
|
|
|
mem_wasted.min 0
|
2013-06-24 14:11:49 +02:00
|
|
|
EOM
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
[ -x $WGET ] && $WGET -q $WGET_FLAGS "$URL?act=$act" -O - && exit 0
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|