-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_opcache_
100 lines (88 loc) · 2.91 KB
/
php_opcache_
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
###############################################################################
#
# Munin plugin to monitor Zend OPCache <http://php.net/manual/en/book.opcache.php>
# By Cédric Nirousset <http://nyrodev.com/>
# Inspired by plugin from 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
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
REQUEST=${0##*/php_opcache_}
if [ "$1" = "config" ]; then
if [ "$REQUEST" = "memory" ]; then
echo "graph_title OPCache Memory usage"
echo "graph_args -l 0 --base 1024"
echo "graph_vlabel Memory usage"
echo "graph_category php-opcache"
echo "graph_order mem_used mem_free mem_wasted"
echo "graph_total Total"
echo "mem_free.label Memory Free"
echo "mem_free.draw STACK"
echo "mem_free.min 0"
echo "mem_used.label Memory Used"
echo "mem_used.draw AREA"
echo "mem_used.min 0"
echo "mem_wasted.label Memory Wasted"
echo "mem_wasted.draw STACK"
echo "mem_wasted.min 0"
elif [ "$REQUEST" = "hitrate" ]; then
echo "graph_title OPCache Hit rate"
echo "graph_args -l 0 --upper-limit 100"
echo "graph_vlabel Hit rate"
echo "graph_category php-opcache"
echo "hitrate.label Hitrate"
echo "hitrate.draw LINE2"
echo "hitrate.min 0"
elif [ "$REQUEST" = "hits" ]; then
echo "graph_title OPCache Hits"
echo "graph_args -l 0"
echo "graph_vlabel Hits per second"
echo "graph_category php-opcache"
echo "hits.label Hits"
echo "hits.draw LINE2"
echo "hits.type DERIVE"
echo "hits.min 0"
elif [ "$REQUEST" = "misses" ]; then
echo "graph_title OPCache Misses"
echo "graph_args -l 0"
echo "graph_vlabel Misses per second"
echo "graph_category php-opcache"
echo "misses.label Misses"
echo "misses.draw LINE2"
echo "misses.type DERIVE"
echo "misses.min 0"
elif [ "$REQUEST" = "keys" ]; then
echo "graph_title OPCache Keys"
echo "graph_args -l 0"
echo "graph_vlabel Keys"
echo "graph_category php-opcache"
echo "graph_order used_keys free_keys"
echo "graph_total Total"
echo "used_keys.label Cached keys"
echo "used_keys.draw AREASTACK"
echo "free_keys.label Free keys"
echo "free_keys.draw AREASTACK"
fi;
exit 0
fi
###############################################################################
[ -x $WGET ] && $WGET -q $WGET_FLAGS "$URL?req=$REQUEST" -O - && exit 0
exit 1