Perl subroutine plug-in

Marc Powell mpowell at ena.com
Fri May 30 21:06:47 CEST 2003


Stab in the dark but can the nagios user read /var/log/alert?

 

--

Marc

 

  _____  

From: Jan van den Berg [mailto:jan at e-commercepark.com] 
Sent: Friday, May 30, 2003 1:06 PM
To: 'Nagios-Users (E-mail)'

 

 

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-lists.org/archive/users/attachments/20030530/1ce58f40/attachment.html>


More information about the Users mailing list