Good afternoon,
I am having an issue with setting up a service check using check_ncpa.py. I am using a match=regex to monitor the services on a remote host for a series of SQL Anywhere databases, however I am trying to filter out any that are ending with "Training". I have the check working when I do a "Run Check Command", however when I go to save the check settings to apply in the configuration I have noticed that a "\" is automatically being inserted in my regex.
Here is the regex that is working:
-t '<<token>>' -P 5693 -M services -q match=regex,service='(^SQL)(?!.*Training).*'
However when I save the check, the below parameters are what is saved:
-t '<<token>>' -P 5693 -M services -q match=regex,service='(^SQL)(?\!.*Training).*'
I've not been able to locate any information in the NCPA documentation indicating why the character is being entered and was hoping that the forum might offer some additional information.
Nagios XI Version is 5.5.11
check_ncpa.py version is 1.1.3
NCPA Version is 2.1.6
Character "\" inserted into regex on save - check_ncpa.py
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Character "\" inserted into regex on save - check_ncpa.p
! is a special char in nagios for the check_command line in the configurations and needs to be escaped
See
https://support.nagios.com/kb/article.php?id=580
notably
See
https://support.nagios.com/kb/article.php?id=580
notably
The reason for the error this time has to do with the !. Nagios uses the ! as an argument separator. What you need to do is escape the ! with a \ so Nagios knows it should be plain text, for example:
Re: Character "\" inserted into regex on save - check_ncpa.p
@scottwilkerson, Thank you for the quick response. Something that I forgot to mention is that the regex with the escape character left out is working to find the services I need, however when the escape character is entered I receive an internal server error. I understand that I'll need to escape the special character in some way, however I'm not understanding why it works when not escaped, however breaks the check when it is escaped. Are you able to expand on that a little? I have tried escaping the "!" like so "\!" as well as "\!!" however neither are working currently.
I'm a bit confused.
I'm a bit confused.
-
SteveBeauchemin
- Posts: 524
- Joined: Mon Oct 14, 2013 7:19 pm
Re: Character "\" inserted into regex on save - check_ncpa.p
I had this issue before.
This may help you work around the constraint.
In /usr/local/nagios/etc/resource.cfg add:
Then, in your service definition in the gui, use $USER9$ instead of the ! character.
becomes
Good Luck
Steve B
This may help you work around the constraint.
In /usr/local/nagios/etc/resource.cfg add:
Code: Select all
#Escaping exclamation points
$USER9$=!
Code: Select all
-t '<<token>>' -P 5693 -M services -q match=regex,service='(^SQL)(?!.*Training).*'Code: Select all
-t '<<token>>' -P 5693 -M services -q match=regex,service='(^SQL)(?$USER9$.*Training).*'Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact: