forked from tjstein/php5-fpm-munin-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpfpm_memory
24 lines (22 loc) · 823 Bytes
/
phpfpm_memory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env perl
#
# Munin plugin for monitoring PHP5-FPM memory usage
#
# Copyright TJ Stein 2010 http://constantshift.com
my $PHP_BIN = exists $ENV{'phpbin'} ? $ENV{'phpbin'} : "php5-fpm";
my $PHP_POOL = exists $ENV{'phppool'} ? $ENV{'phppool'} : "www";
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
print "graph_title PHP5-FPM Memory Usage ( $PHP_POOL )\n";
print "graph_vlabel RAM\n";
print "graph_category PHP\n";
print "ram.label ram\n";
print "graph_args --base 1024\n";
} else {
my $i = Integer;
@cmd = `ps auwx | grep "$PHP_BIN: pool $PHP_POOL" | grep -v grep | grep -v phpfpm_memory`;
foreach (@cmd) {
@return = split(/ +/, $_);
$i += @return[5]*1024;
}
print "ram.value ".$i."\n";
}