Page 1 of 1

RegEx Breaking ARG into 2 ARGs

Posted: Wed Aug 13, 2014 11:09 am
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.

Re: RegEx Breaking ARG into 2 ARGs

Posted: Wed Aug 13, 2014 11:33 am
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

Re: RegEx Breaking ARG into 2 ARGs

Posted: Wed Aug 13, 2014 12:06 pm
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.

Re: RegEx Breaking ARG into 2 ARGs

Posted: Wed Aug 13, 2014 12:08 pm
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.

Re: RegEx Breaking ARG into 2 ARGs

Posted: Wed Aug 13, 2014 12:19 pm
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?

Re: RegEx Breaking ARG into 2 ARGs

Posted: Wed Aug 13, 2014 12:25 pm
by tmcdonald
Nagios will need to be restarted.

Re: RegEx Breaking ARG into 2 ARGs

Posted: Wed Aug 13, 2014 12:40 pm
by dworthcsl
Thanks again.