[Nagios-devel] Patch for ePN p1.pl

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Patch for ePN p1.pl

Post by Guest »

--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


There's a bug in the ePN p1.pl shipped with Nagios 2.0 final, where
only the output of the very last print / printf is retained and
reported, leading to plugins that work from the command line
generating bogus "No output from plugin" messages under ePN. I've
discussed this with Stanley Hopcroft and he's confirmed the bug.

Patch attached that fixes the bug, while retaining the current
limitations on message length and multi-line output.

Cheers,
Gavin

--
Open Fusion - Open Source Business Solutions [ Linux - Perl - Apache ]
http://www.openfusion.com.au
http://www.sharebot.net
- Fashion is a variable, but style is a constant - Programming Perl

--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="p1-print.pl.patch"

--- p1.pl.dist 2006-03-21 11:42:30.000000000 +1100
+++ p1.pl 2006-03-21 11:56:16.000000000 +1100
@@ -69,27 +69,29 @@

sub TIEHANDLE {
my ($class) = @_;
- my $me ;
+ my $me = '';
bless \$me, $class;
}

sub PRINT {
my $self = shift;
- $$self = substr(join('',@_), 0, 256) ;
- # $$self .= substr(join('',@_), 0, 256) ;
+ # $$self = substr(join('',@_), 0, 256) ;
+ $$self .= substr(join('',@_), 0, 256) ;
}

sub PRINTF {
my $self = shift;
my $fmt = shift;
- $$self = substr(sprintf($fmt,@_), 0, 256) ;
- # $$self .= substr(sprintf($fmt,@_), 0, 256) ;
+ # $$self = substr(sprintf($fmt,@_), 0, 256) ;
+ $$self .= substr(sprintf($fmt,@_), 0, 256) ;
}

sub READLINE {
my $self = shift;
+ # Omit all lines after the first, per the nagios plugin guidelines
+ $$self = (split /\n/, $$self)[0];
# Perl code other than plugins may print nothing; in this case return "(No output!)\n".
- return $$self ? $$self : "(No output!)\n" ;
+ return $$self ? substr($$self, 0, 256) : "(No output!)\n" ;
}

sub CLOSE {

--7JfCtLOvnd9MIVvH--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked