Sha256: 719087645269a45644b077718efe11f4a04551b1c4301674dacaf614c59704e3

Contents?: true

Size: 1.77 KB

Versions: 7

Compression:

Stored size: 1.77 KB

Contents

#!/usr/bin/perl
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf

my $ret = undef;

if (! eval "require LWP::UserAgent;")
{
	$ret = "LWP::UserAgent not found";
}

my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/status";
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);

if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
{
	if ($ret)
	{
		print "no ($ret)\n";
		exit 1;
	}

	my $ua = LWP::UserAgent->new(timeout => 30);

	my @badports;
	foreach my $port (@PORTS) {
		my $url = sprintf $URL, $port;
		my $response = $ua->request(HTTP::Request->new('GET',$url));
		push @badports, $port unless $response->is_success and $response->content =~ /^accepted conn:/im;
	}
	if (@badports) {
		print "no (phpfpm-status)\n";
		exit 1;
	} else {
		print "yes\n";
		exit 0;
	}
}

if ( defined $ARGV[0] and $ARGV[0] eq "config" )
{
	print('graph_title PHP5-FPM Status
graph_args --base 1024 -l 0
graph_vlabel Connections
graph_category PHP
graph_order Idle Active Total
graph_info Plugin created by TJ Stein
idle.label Idle
idle.draw AREA
active.label Active
active.draw AREA
total.label Total
total.draw STACK
');

	exit 0;
}

foreach my $port (@PORTS)
{
    my $ua = LWP::UserAgent->new(timeout => 30);
    my $url = sprintf $URL, $port;
    my $response = $ua->request(HTTP::Request->new('GET',$url));
	if ($response->content =~ /idle processes:\s+([0-9\.]+)/im) {
        print "idle.value $1\n";
    } else {
        print "idle.value U\n";
    }
	if ($response->content =~ /active processes:\s+([0-9\.]+)/im) {
        print "active.value $1\n";
    } else {
        print "active.value U\n";
    }
	if ($response->content =~ /total processes:\s+([0-9\.]+)/im) {
        print "total.value $1\n";
    } else {
        print "total.value U\n";
    }
}

# vim:syntax=perl

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
salted-rails-0.0.9 salt/munin/files/php5-fpm/plugins/phpfpm_status
salted-rails-0.0.8 salt/munin/files/php5-fpm/plugins/phpfpm_status
salted-rails-0.0.7 salt/munin/files/php5-fpm/plugins/phpfpm_status
salted-rails-0.0.6 salt/munin/files/php5-fpm/plugins/phpfpm_status
salted-rails-0.0.5 salt/munin/files/php5-fpm/plugins/phpfpm_status
salted-rails-0.0.4 salt/munin/files/php5-fpm/plugins/phpfpm_status
salted-rails-0.0.2 salt/munin/files/php5-fpm/plugins/phpfpm_status