Closed Rohlik closed 6 years ago
Only when you add some own code:
my $counter = 0;
@searches = ({
...
criticalpatterns => ["Core handshake", "Na core odeslano 0"],
options => "supersmartscript",
script => sub {
# every time a criticalpattern matches, we land here
my $line = $ENV{CHECK_LOGFILES_SERVICEOUTPUT};
if ($line =~ /handshake/) {
counter = 0;
return 0;
} elsif ($line =~ /transakci/) {
if ($counter >= 4) {
$counter = 0;
print "4 times in a row Na core odeslano 0 transakci";
return 2;
} else {
$counter++;
return 0; # only increase the counter. occurrence 1, 2, 3 have no effect else
}
} else {
# if you have more than just these two types of text, then you must write
# criticalpatterns => [".*"]
return 0; # forget this line
}
},
Thx so much
It is possible to scan logfile for a pattern and alarm when it is found X in row?
For example I have this log:
and I want critical state occur only if pattern
Na core odeslano 0 transakci
is found 4 or more in a row.Thx for your time.