0

I try to use your CPAN-module POE::Compoenten::Server::NRPE. I tried the sample from the CPAN-site and tested against nagios-tool check_nrpe.

the text was fine, but I am not able to get the correct return-value. you described this return_result in the modules-description, but I am not aware how to use it.

would be very nice, if you can give me a very short example, how to return a value <> 0.

thanks a lot!

cheers, christoph

use POE;
use POE::Component::Server::NRPE;

# test with: check_nrpe -H localhost -c test; echo $?

my $nrped = POE::Component::Server::NRPE->spawn (port => 5666);
$nrped->add_command (command => "test", program =>
sub { print STDOUT "test CRITICAL\n";
return 2;    # always 0???
});

$poe_kernel->run ();
return 0; 
chris01
  • 10,921
  • 9
  • 54
  • 93

2 Answers2

1

Thank you for posting this question. I was unaware of this module but it will be of great help to me.

  1. Try using strict and warning in your code, it is for your good
  2. Use return constants provided by POE::Component::Server::NRPE::Constants instead of using 0 for OK, 1 for WARNING and so on
  3. I believe the only problem was that you were using return 2 instead of exit 2 or better yet exit NRPE_STATE_CRITICAL in the test sub

The following code should yield the required result

use strict;
use warnings;
use POE;
use POE::Component::Server::NRPE;

# it's recommended to use the NRPE return states provided by the module
use POE::Component::Server::NRPE::Constants qw(NRPE_STATE_OK NRPE_STATE_CRITICAL);

my $nrped = POE::Component::Server::NRPE->spawn (
        port => 5666
);

$nrped->add_command (command => "test", program =>
        sub {
                print STDOUT "testing CRITICAL\n";
        # better to use NRPE_STATE_CRITICAL...
                exit NRPE_STATE_CRITICAL;
        # ... instead of the corresponding digital value
        # but it should work
        # exit 2;
        }
);

$poe_kernel->run ();
exit 0;

Thanks

Ashish Kumar
  • 811
  • 4
  • 8
0

looks like a bug in the module. the author pushed a new version (0.16 -> 0.18) on cpan.

bmu
  • 35,119
  • 13
  • 91
  • 108
chris01
  • 10,921
  • 9
  • 54
  • 93