mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Add PHP OPcache plugin
This commit is contained in:
parent
279697003a
commit
cde616b8d0
2 changed files with 86 additions and 0 deletions
58
plugins/php/php_opcache
Normal file
58
plugins/php/php_opcache
Normal file
|
@ -0,0 +1,58 @@
|
|||
#!/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
|
||||
[ -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"
|
||||
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
|
||||
graph_category nginx
|
||||
graph_order mem_used mem_free
|
||||
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
|
||||
EOM
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
|
||||
[ -x $WGET ] && $WGET -q $WGET_FLAGS "$URL?act=$act" -O - && exit 0
|
||||
|
||||
exit 1
|
||||
|
28
plugins/php/php_opcache.php
Normal file
28
plugins/php/php_opcache.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Part of Munin PHP OPcache plugin - Refer to php_opcache for installation instructions.
|
||||
*/
|
||||
|
||||
if (function_exists('opcache_get_status'))
|
||||
{
|
||||
$data = opcache_get_status();
|
||||
$output = array(
|
||||
'mem_used.value' => $data['memory_usage']['used_memory'],
|
||||
'mem_free.value' => $data['memory_usage']['free_memory'],
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// OPCache not installed :(
|
||||
$output = array(
|
||||
'mem_used.value' => 0,
|
||||
'mem_free.value' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
header('Content-Type: text/plain');
|
||||
foreach ($output as $key => $value)
|
||||
{
|
||||
echo $key, ' ', $value, "\n";
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue