check_log not working properly

Neil neil-on-nagios at restricted.dyndns.org
Fri Feb 13 08:09:52 CET 2004


Jim Mozley writes:
> 
> watchfor /pattern-i-want-to-match/
>         exec /path/to/my/script.pl $* 
> 
> 
> if ( $syslogmsg =~ /down/ ) {
> 	$nagios_code = 2; # Critical
> } 
> 
> my $cmd = "[$epoch] 
> PROCESS_SERVICE_CHECK_RESULT;$host;$service;$nagios_code;$msg"; 
> 
> And fire it into nagios: 
> 
> my $echo = '/usr/bin/echo';
> my $pipe = '/usr/local/nagios/var/rw/nagios.cmd'; 
> 
> system "$echo \"$cmd\" >> $pipe";

Hi Jim, 

For my testing, I use swatch and I have it tailed /var/log/test.log
Then on my /etc/swatch.conf: 

watchfor        /down/
               exec /usr/local/src/script.pl $* 

I executed swatch as daemon. I populated test.log: 

echo down >> /var/log/test.log 

then I check nagios.cmd if it was populated. Yes it was populated. But I was 
wondering why pattern didn't match the string "down". It's because the 
contents of nagios.cmd is just this: 

[] PROCESS_SERVICE_CHECK_RESULT;;;; 

This was my pattern:
if ( $syslogmsg =~ /down/ ) { 

I also tried $_ still didn't work. 

So how can the $* be read by the script.pl? One more, I also even tried this 
pattern 

if ( $ARGV[0] =~ /down/ ) {
didn't work too. 

Any help is greatly appreciated. 

Neil 



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list