Nagios-NRPE
view release on metacpan or search on metacpan
lib/Nagios/NRPE/Daemon.pm view on Meta::CPAN
my ($code, $return) = $self->{callback}($self, $command, @options);
eval {
print $s $packet->assemble(
version => $version,
type => NRPE_PACKET_RESPONSE,
result_code => $code,
check => $return
);
};
close($s);
}
}
}
=pod
=over
=item commandlist()
A hashref of elements that are valid commands.
An example for it is:
"check_cpu" => { bin => "/usr/lib/nagios/plugin/check_cpu",
args => "-w 50 -c 80" }
C<args> can contain $ARG1$ elements like normal nrpe.cfg command elements.
=back
=cut
sub commandlist
{
my $self = shift;
return $self->{commandlist};
}
=pod
=over
=item create_socket()
A shorthand function returning either an encrypted or unencrypted socket
depending on wether ssl is set to 1 or 0.
=back
=cut
sub create_socket
{
my $self = shift;
my $socket;
if ($self->{ssl})
{
eval {
# required for new IO::Socket::SSL versions
require IO::Socket::SSL;
IO::Socket::SSL->import();
IO::Socket::SSL::set_ctx_defaults(SSL_verify_mode => 0);
};
my $options = {
Listen => 5,
LocalAddr => $self->{listen},
LocalPort => $self->{port},
Proto => 'tcp',
Reuse => 1,
SSL_verify_mode => 0x01,
Type => SOCK_STREAM
};
if ($self->{SSL_cipher_list})
{
$options->{SSL_cipher_list} = $self->{SSL_cipher_list};
}
if ($self->{SSL_cert_file} && $self->{SSL_key_file})
{
$options->{SSL_cert_file} = $self->{SSL_cert_file};
$options->{SSL_key_file} = $self->{SSL_key_file};
}
$socket = IO::Socket::SSL->new(%{$options})
or die(IO::Socket::SSL::errstr());
}
else
{
$socket = IO::Socket::INET6->new(
Listen => 5,
LocalAddr => $self->{listen},
LocalPort => $self->{port},
Reuse => 1,
Proto => 'tcp',
Type => SOCK_STREAM
) or die "ERROR: $@ \n";
}
return $socket;
}
=pod
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by the authors (see AUTHORS file).
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
1;
( run in 0.469 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )