FAQ

John W. Krahn wrote:
Tim Wolak wrote:
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::/) {
Correction, you are examining every odd numbered line for /^EFIXException::/
and every even numbered line for /^Read failed on socket/.

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

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 9 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedJan 13, '05 at 3:15p
activeJan 17, '05 at 12:04a
posts9
users7
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase