THIS KNOWLEDGE BASE HAS BEEN ARCHIVED AND IS NO LONGER BEING UPDATED
Please visit library.nagios.com/docs for the latest and most up-to-date documentation.
Home » Categories » Multiple Categories

Nagios XI - Special Characters

Overview

Nagios XI, as well as the Linux command line interface, have some reserved characters that need to be escaped in specific ways.

Special characters are a group of characters that carry out special instructions, like the dollar sign $ which does expansion in bash. If you tried to use a $ in a password argument at the command line you will see it throw an unexpected error.

The term "escaped" or "escaping" is when you use a character like the backslash \ to identifying that the next character should be treated as plain text, like the $ in a password.

In Nagios Configurations an exclamation mark ! is used as an argument separator. If you used this in a password then the password will be split and it will change the amount of arguments being presented to the monitoring engine.

This KB article demonstrates this behaviour and provides some solutions.

 

Command Line Example

This example shows you a password of $ecret! being used with the check_wmi_plus.pl plugin:

/usr/local/nagios/libexec/check_wmi_plus.pl -H 10.25.14.3 -u wmiagent -p $ecret! -m checkcpu -w '80' -c '90'

 

It produces this error message:

UNKNOWN - The WMI query had problems. You might have your username/password wrong or the user's access level is too low. Wmic error text on the next line.
[librpc/rpc/dcerpc_util.c:1290:dcerpc_pipe_auth_recv()] Failed to bind to uuid 4d9f4ab8-7d1c-11cf-861e-0020af6e7c57 - NT_STATUS_NET_WRITE_FAULT
[librpc/rpc/dcerpc_connect.c:790:dcerpc_pipe_connect_b_recv()] failed NT status (c0000022) in dcerpc_pipe_connect_b_recv
[wmi/wmic.c:196:main()] ERROR: Login to remote object.
NTSTATUS: NT_STATUS_ACCESS_DENIED - Access denied

 

Here is that example again but this time the $ is being escaped:

/usr/local/nagios/libexec/check_wmi_plus.pl -H 10.25.14.3 -u wmiagent -p \$ecret! -m checkcpu -w '80' -c '90'

 

This time it worked:

OK (Sample Period 246 sec) - Average CPU Utilisation 0.34%|'Avg CPU Utilisation'=0.34%;80;90;

 

The next section uses this example in Core Configuration Manager.

 

 

Core Configuration Manager Example

This example shows you a password of $ecret! being used with the check_wmi_plus.pl plugin. Reading the previous section you know that you need to escape the $ sign. This example assumes that the password is stored in the $ARG2$ field for the service definition:

\$ecret!

 

However after making that change and applying configuration you still receive errors like:

UNKNOWN - The WMI query had problems. You might have your username/password wrong or the user's access level is too low. Wmic error text on the next line.
[librpc/rpc/dcerpc_util.c:1290:dcerpc_pipe_auth_recv()] Failed to bind to uuid 4d9f4ab8-7d1c-11cf-861e-0020af6e7c57 - NT_STATUS_NET_WRITE_FAULT
[librpc/rpc/dcerpc_connect.c:790:dcerpc_pipe_connect_b_recv()] failed NT status (c0000022) in dcerpc_pipe_connect_b_recv
[wmi/wmic.c:196:main()] ERROR: Login to remote object.
NTSTATUS: NT_STATUS_ACCESS_DENIED - Access denied

 

The reason for the error this time has to do with the $ (again). Nagios is seeing the $ and thinks this is the beginning of a macro / free variable, for example $USER1$. What you need to do is escape the $ with another $ so Nagios knows it should be plain text, for example:

\$$ecret!

 

You still need the \ as Nagios needs this for the command line. However after making that change and applying the configuration you may still get the same error:

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:

\$$ecret\!

 

After applying the configuration the service now works. Nagios XI 5.4.0 and newer will automatically escape the ! with a \. Here is a screenshot showing the final password stored in the $ARG2$ field:

 

 

As you can imagine special characters can make things complicated. The next section provides solutions for special characters.

 

 

Solutions

One solution is to define the password in a user macro in resources.cfg that can be used in your object definitions. This provides an additional benefit of storing the password in a central location and hides it from plain sight. Please refer to the following documentation for detailed steps on how to implement this solution:

Documentation - Understanding The User Macros Component

 

Some plugins such as check_wmi_plus.pl provide the ability to use a dedicated file to store credentials in. This solution is specific to the plugin being used, not all plugins provide this capability. Please refer to the following documentation for detailed steps on how to implement an authentication file with check_wmi_plus.pl:

Documentation - Monitoring Windows Using WMI

 

 

Object Name & Macro Output

While not specifically related to this article, there are two directives in the nagios.cfg file  that dictate what characters cannot be used for object names and macro output. Please refer to the following documentation for detailed information:

Illegal Object Name Characters

Illegal Macro Output Characters 

 

 

More Information

The following link provides detailed information on special characters:

http://mywiki.wooledge.org/BashGuide/SpecialCharacters

 

 

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/



Special Offer For Knowledgebase Visitors! Get a huge discount on Nagios Log Server by clicking below.

Get 60% Off Nagios Log Server!

Did you know? Nagios provides complete monitoring of: Windows, Linux, UNIX, Servers, Websites, SNMP, DHCP, DNS, Email, Storage, Files, Apache, IIS, EC2, and more!

2.33 (3)
Article Rating (3 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
Nagios XI - Core Config Manager - How It Works
Viewed 6298 times since Sun, Jul 30, 2017
Nagios XI - Custom Wizards, Components and Dashlets - NWC12
Viewed 10913 times since Thu, Feb 4, 2016
Adding MATCH Statements in the SNMP Trap Interface
Viewed 7144 times since Fri, Jul 30, 2021
Nagios Core - Passive Host State Translation
Viewed 7319 times since Mon, Feb 1, 2016
Managing Host Templates
Viewed 12402 times since Mon, Jun 28, 2021
Nagios XI - Offloading MySQL to Remote Server
Viewed 10299 times since Thu, Jan 28, 2016
Nagios XI - Monitoring AIX With Nagios
Viewed 9256 times since Thu, Jan 28, 2016
Nagios XI - Configuring Passive Services With Nagios XI
Viewed 8195 times since Wed, Jan 27, 2016
Nagios Core - The Art & Zen of Managing Nagios with Puppet - NWC14
Viewed 21492 times since Mon, Feb 8, 2016
Nagios XI - Receiving SNMP Traps From Nagios Network Analyzer
Viewed 9097 times since Mon, Oct 17, 2016