-
Notifications
You must be signed in to change notification settings - Fork 45
/
phpfpm_memory
61 lines (43 loc) · 1.32 KB
/
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
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
#!/usr/bin/perl
# -*- perl -*-
=encoding utf8
=head1 NAME
phpfpm_connections - Munin plugin for monitoring PHP-FPM memory usage.
=head1 CONFIGURATION
You might need to specify connection parameters in the plugin
configuration to override the defaults. These are the defaults:
[phpfpm_*]
env.phpbin php-fpm
env.phppool www
=head1 PARAMETERS:
config (required)
autoconf (optional - used by munin-config)
=over
=head1 LICENSE
Copyright TJ Stein 2010 http://constantshift.com
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
my $PHP_BIN = exists $ENV{'phpbin'} ? $ENV{'phpbin'} : "php-fpm";
my $PHP_POOL = exists $ENV{'phppool'} ? $ENV{'phppool'} : "www";
if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
{
print "yes\n";
exit 0;
}
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
print "graph_title PHP-FPM Memory Usage\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";
}