NAME
POE::Component::Client::NRPE - a POE Component that implements check_nrpe functionality
SYNOPSIS
# A simple 'check_nrpe' version 2 clone
use strict;
use POE qw(Component::Client::NRPE);
use Getopt::Long;
$|=1;
my $command;
my $hostname;
my $return_code;
GetOptions("host=s", \$hostname, "command=s", \$command);
unless ( $hostname ) {
$! = 3;
die "No hostname specified\n";
}
POE::Session->create(
inline_states => {
start =>
sub {
POE::Component::Client::NRPE->checknrpe(
host => $hostname,
command => $command,
event => '_result',
);
return;
},
_result =>
sub {
my $result = $[ARG0];
print STDOUT $result->{data}, "\n";
$returncode = $result->{result};
return;
},
}
);
$poe_kernel->run();
exit($return_code);
DESCRIPTION
POE::Component::Client::NRPE is a POE component that implements version 1 and version 2 of the nrpe (Nagios Remote Plugin Executor) client, check_nrpe. It also supports SSL encryption using Net::SSLeay and a hacked version of POE::Component::SSLify.
CONSTRUCTOR
check_nrpe
Takes a number of parameters:
'host', the hostname or IP address to connect to, mandatory;
'event', the event handler in your session where the result should be sent, mandatory;
'session', optional if the poco is spawned from within another session;
'port', the port to connect to, default is 5666;
'version', the NRPE protocol version to use, default is 2;
'usessl', set this to 0 to disable SSL support with NRPE Version 2, default is 1;
'command', the command to run remotely, default is 'NRPECHECK';
'context', anything you like that'll fit in a scalar, a ref for instance;
The 'session' parameter is only required if you wish the output
event to go to a different session than the calling session, or if
you have spawned the poco outside of a session.
The poco does it's work and will return the output event with the
result.
OUTPUT EVENT
This is generated by the poco. ARG0 will be a hash reference with the following keys:
'version', the NRPE protocol version;
'host', the hostname given;
'command', the command that was run;
'context', anything that you specified;
'result', the Nagios result code, can be 0,1,2 or 3;
'data', what the NRPEd gave us by way of output;
AUTHOR
Chris "BinGOs" Williams <chris@bingosnet.co.uk>
This module uses code derived from
<http://www.stic-online.de/stic/html/nrpe-generic.html> Copyright (C)
2006, 2007 STIC GmbH, http://www.stic-online.de
SEE ALSO
POE
POE::Component::SSLify