Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (43 sloc) 1.32 KB
#!/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";
}