consol labs check_logfiles second crit pattern doesnt work
Posted: Wed Aug 05, 2020 2:46 am
Hi
I want to use this check to check logfiles
if it contains one of 2 critical patterns that mean show critical alert in nagios
First critical pattern is
MemoryException: xxx bytes not availableI need that check give critical if xxx more than n bytes
I know that xxx > 3.5 gb in bytes and in this case check must be In critical state
This is completed and worked
I want to add second critical pattern TradeBase: not enough memory for index
And problem is that check ignore second critical pattern
I'm trying different variants but no one worked
my config for check now is
Script author replied
What you can try ist o use this as an example….
criticalpatterns => {
'door-open' => 'Door is open! (.*)',
'door-closed' => 'Door is closed! (.*)' },
options => 'script,capturegroups',
script => sub {
my $state = $CHECK_LOGFILES_PRIVATESTATE;
my $date = $ENV{CHECK_LOGFILES_CAPTURE_GROUP1};
printf STDERR "%s\n", $ENV{CHECK_LOGFILES_KAKA};
#... umrechnen in einen epoch-timestamp
if ($ENV{CHECK_LOGFILES_PATTERN_KEY} eq 'door-closed') {
delete $state->{opening_time};
printf "Door %s is closed\n", $ENV{CHECK_LOGFILES_TAG};
return 0;
} elsif ($ENV{CHECK_LOGFILES_PATTERN_KEY} eq 'door-open') {
Criticalpatterns is written as key-value structure.
$ENV{CHECK_LOGFILES_PATTERN_KEY} is the key of the matching pattern
$ENV{CHECK_LOGFILES_CAPTURE_GROUP1} is the portion inside ()
I cant understand how to add second critical pattern (((
Can someone help?
I want to use this check to check logfiles
if it contains one of 2 critical patterns that mean show critical alert in nagios
First critical pattern is
MemoryException: xxx bytes not availableI need that check give critical if xxx more than n bytes
I know that xxx > 3.5 gb in bytes and in this case check must be In critical state
This is completed and worked
I want to add second critical pattern TradeBase: not enough memory for index
And problem is that check ignore second critical pattern
I'm trying different variants but no one worked
my config for check now is
Code: Select all
@searches = ({
logfile => "test.log",
criticalpatterns => {'MemoryException: (\d+) bytes not available',
'TradeBase: not enough memory for index(.*)'},
options => "supersmartscript, capturegroups,noprotocol",
script => sub {
my $gigabytes = $ENV{CHECK_LOGFILES_CAPTURE_GROUP1} / (1024*1024*1024);
if ($gigabytes > 3.5) {
print $ENV{CHECK_LOGFILES_SERVICEOUTPUT};
return 2;
} else {
return 0;
}
},
});
What you can try ist o use this as an example….
criticalpatterns => {
'door-open' => 'Door is open! (.*)',
'door-closed' => 'Door is closed! (.*)' },
options => 'script,capturegroups',
script => sub {
my $state = $CHECK_LOGFILES_PRIVATESTATE;
my $date = $ENV{CHECK_LOGFILES_CAPTURE_GROUP1};
printf STDERR "%s\n", $ENV{CHECK_LOGFILES_KAKA};
#... umrechnen in einen epoch-timestamp
if ($ENV{CHECK_LOGFILES_PATTERN_KEY} eq 'door-closed') {
delete $state->{opening_time};
printf "Door %s is closed\n", $ENV{CHECK_LOGFILES_TAG};
return 0;
} elsif ($ENV{CHECK_LOGFILES_PATTERN_KEY} eq 'door-open') {
Criticalpatterns is written as key-value structure.
$ENV{CHECK_LOGFILES_PATTERN_KEY} is the key of the matching pattern
$ENV{CHECK_LOGFILES_CAPTURE_GROUP1} is the portion inside ()
I cant understand how to add second critical pattern (((
Can someone help?