Hello all,
Hello,
I have a script that is checking a service to see if its running and that its log file does not contain two error message to confirm that it has not died. However the subrutine is just saying its up when I have put the error message in the last line of the log to make sure it sees that its down. Please have a look at the code snipit and any help would be great.
sub grepstring { open LOG, "tail gw_20050105.log |", or die "Log file not found $!";
Since you are using a piped open you should also close() the filehandle and verify that it closed correctly.
perldoc -f close perldoc perlopentut
You should probably also use a lexically scoped filehandle.
while (<LOG>) { $newlog = <LOG>;
You putting the first line into $_ and the second line into $newlog so you are only examining the contents of every second line.
if ($newlog =~ /^Read failed on socket/ || /^EFIXException::/) { exit $exit_codes{'CRITICAL'}; print "Log entry can not be found GW down!\n"; } else { print "GW is UP!\n"; exit $exit_codes{'OK'}; } } }
John -- use Perl; program fulfillment
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>