mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Merge pull request #457 from zbal/php-fpm-status
Add unix socket support, change some indent / format.
This commit is contained in:
commit
8a91cd30f7
1 changed files with 53 additions and 32 deletions
|
@ -17,11 +17,17 @@ You will need the perl fastcgi::client on your host
|
|||
|
||||
You have to put this in your plugin.conf.d folder
|
||||
|
||||
# If your php process is listening on TCP
|
||||
[php_fpm_process]
|
||||
env.serveraddr 127.0.0.1
|
||||
env.port 9000
|
||||
env.path /status
|
||||
|
||||
# If your php process is listening on Unix Socket
|
||||
[php_fpm_process]
|
||||
env.sock /var/run/php5-fpm.sock
|
||||
env.path /status
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
|
@ -41,8 +47,6 @@ GNU General Public License, version 3
|
|||
|
||||
=cut
|
||||
|
||||
|
||||
use IO::Socket::INET;
|
||||
use FCGI::Client;
|
||||
|
||||
my $ish = 1;
|
||||
|
@ -55,18 +59,33 @@ my $TOTAL = 0;
|
|||
my $SERVERADDR = $ENV{'serveraddr'} || "127.0.0.1";
|
||||
my $PORT = $ENV{'port'} || "9000";
|
||||
my $PATH = $ENV{'path'} || "/status";
|
||||
my $UNIX_SOCK = $ENV{'sock'};
|
||||
|
||||
my $sock = IO::Socket::INET->new(
|
||||
my $sock;
|
||||
|
||||
if ($UNIX_SOCK) {
|
||||
use IO::Socket::UNIX;
|
||||
$sock = IO::Socket::UNIX->new(
|
||||
Peer => $UNIX_SOCK,
|
||||
);
|
||||
if (!$sock) {
|
||||
print "Server maybe down, unabled to connect to $UNIX_SOCK";
|
||||
exit 2;
|
||||
}
|
||||
} else {
|
||||
use IO::Socket::INET;
|
||||
$sock = IO::Socket::INET->new(
|
||||
PeerAddr => $SERVERADDR,
|
||||
PeerPort => $PORT,
|
||||
);
|
||||
|
||||
if (!$sock) {
|
||||
print "Server maybe down, unabled to connect to $SERVERADDR:$PORT";
|
||||
exit 2;
|
||||
}
|
||||
}
|
||||
|
||||
my $client = FCGI::Client::Connection->new( sock => $sock );
|
||||
|
||||
my ( $stdout, $stderr, $appstatus ) = $client->request(
|
||||
+{
|
||||
REQUEST_METHOD => 'GET',
|
||||
|
@ -119,6 +138,8 @@ if ( defined $ARGV[0] and $ARGV[0] eq "config" )
|
|||
exit 0
|
||||
}
|
||||
|
||||
print $body;
|
||||
|
||||
if($body =~ m/idle processes: (.*?)\n/) {
|
||||
$IDLE = $1;
|
||||
print "idle.value ".$IDLE."\n";
|
||||
|
|
Loading…
Reference in a new issue