[Nagiosplug-devel] Perl subroutine

Jan van den Berg jan at e-commercepark.com
Fri May 30 11:30:10 CEST 2003


Hi there,

 

I don't if this is the right place here, but I have a question about a
plug-in I'm developing.

 

See the following Perl sub-routine

 

sub get_alert

        {

        local @ARGV = '/var/log/alert';

        my @last8;

  

        while (<>) {

                push @last8, $_;

                shift @last8 while @last8 > 8;

                        }

                        my $line = $last8[-6];

                        my $line =~ y/[,'"()<>]:;0123456789*//d;


                        print $line;   

                        #print "test";

        }

 

So what this does is, get the 8 before last line from a log file, strips
this line from meta-characters and print out a clean line of text. When
I run this command-line: no problem. However Nagios says there is no
output! But when I uncomment the print "test"; it prints this out nicely
in Nagios... so the subroutine is okay, and the print statement is okay.

 (I also tried using quotes around "$line" but that didn't work).

 

So what am I doing wrong here?

 

Please help.

 

Jan van den Berg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20030530/d3d80f1b/attachment.html>


More information about the Devel mailing list