RegEx Breaking ARG into 2 ARGs

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dworthcsl
Posts: 95
Joined: Wed Jan 11, 2012 4:00 pm

RegEx Breaking ARG into 2 ARGs

Post by dworthcsl »

Hi,

I am trying to put in an exclude argument into the check_oracle_health. When I put the arg string into $ARG1$ and save, it splits it at the "!". I tested the string by running it on the command line and it works. I also replaced the "!" with another "?" and that did not split the ARG into 2. I also tried to escape the "!", but that did not work.

Here is the ARG string.

Code: Select all

--encode --connect "DB_instance" --username user --password "passwd" --mode tablespace-usage "^(?\!UNDO*$)" --regex --warning 90 --critical 95
It splits as follows:

Code: Select all

$ARG1$ = --encode --connect "DB_instance" --username user --password "passwd" --mode tablespace-usage "^(?

$ARG2$ = UNDO*$)" --regex --warning 90 --critical 95
The command is:

Code: Select all

/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 $USER1$/check_oracle_health $ARG1$
Something special about the ! that would cause ARGs to be split? Is there a way around it?

I am running 2014 R1.3 on RHEL 6.5.

Thanks.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: RegEx Breaking ARG into 2 ARGs

Post by tmcdonald »

The "!" character is used to separate arguments in the Nagios Core config files. Since XI runs on top of Core, the "!" is not an allowed character in the commands. One trick to get around it is to add "!" as a USER macro in resource.cfg like so:

/usr/local/nagios/etc/resource.cfg

Code: Select all

# Path to the plugins
$USER1$=/usr/local/nagios/libexec

# Port for NSClient++
$USER7$=12489

# Password for NSClient++
$USER8$=secret

#Escaping exclamation points
$USER9$=!
Then in your definition, set your ARG to use $USER9$ wherever you need the exclamation:
exclamation.png
hello world.png
You do not have the required permissions to view the files attached to this post.
Former Nagios employee
dworthcsl
Posts: 95
Joined: Wed Jan 11, 2012 4:00 pm

Re: RegEx Breaking ARG into 2 ARGs

Post by dworthcsl »

I added the user defined macro in resource.cfg.

Code: Select all

# Path to the plugins
$USER1$=/usr/local/nagios/libexec

# Path to event handlers
#$USER2$=/usr/local/nagios/libexec/eventhandlers

# Port for NSClient++
$USER7$=12489
# Password for NSClient++
$USER8$=secret

#Escaping exclamation points
$USER9$=!
I then updated the ARG1

Code: Select all

--encode --connect "DBName" --username user --password "passwd" --mode tablespace-usage '^(?$USER9$(UNDO*))' --regex --warning 90 --critical 95
The ARG was not split, but the regex was not picked up. I ran it on the command line and it worked. Do I need to do anything to get the macro pulled in? I did not see anything inside XI, so I just edited the file. Also tried restarting nagios.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: RegEx Breaking ARG into 2 ARGs

Post by tmcdonald »

How were you testing this? Did you use the Test Check Command or did you apply config and let the check run? The Test Check Command button has some issues with escaping and won't work in all cases.
Former Nagios employee
dworthcsl
Posts: 95
Joined: Wed Jan 11, 2012 4:00 pm

Re: RegEx Breaking ARG into 2 ARGs

Post by dworthcsl »

Never mind it works. I created a check with dummy to see if it was coming through. Then realized I was missing an argument for the check_oracle_health. Thanks again for your help.

Just curious, if I wanted to add another macro, is a restart in nagios required or just editing the file is enough?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: RegEx Breaking ARG into 2 ARGs

Post by tmcdonald »

Nagios will need to be restarted.
Former Nagios employee
dworthcsl
Posts: 95
Joined: Wed Jan 11, 2012 4:00 pm

Re: RegEx Breaking ARG into 2 ARGs

Post by dworthcsl »

Thanks again.
Locked