consol labs check_logfiles second crit pattern doesnt work

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
AgentZoy
Posts: 3
Joined: Wed Aug 05, 2020 2:35 am

consol labs check_logfiles second crit pattern doesnt work

Post by AgentZoy »

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

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;
    }
  },
});
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?
AgentZoy
Posts: 3
Joined: Wed Aug 05, 2020 2:35 am

Re: consol labs check_logfiles second crit pattern doesnt wo

Post by AgentZoy »

So one more time thing
It's check only in this way
If during check last line in log file meet critical pattern it show critical state
No new records added to log file
run check
give ok pattern

How i can modify it if it found critical pattern once it stays in critical

Yes and link to check https://labs.consol.de/nagios/check_log ... parameters
Locked