WMI Servicecheck SQL instance - special character

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
OptimusB
Posts: 146
Joined: Mon Oct 27, 2014 10:08 pm
Location: Canada
Contact:

WMI Servicecheck SQL instance - special character

Post by OptimusB »

I am trying to monitor a MSSQL service and the service name has a special character $ in it. I am using WMI plus with checkservice for this. When testing the command with core config manager, it seems to work. But when I check the dashboard it says 0 services found.

Here's the test command (modified service name, but kept the $ character) output from XI CCM.

Code: Select all

COMMAND: /usr/local/nagios/libexec/check_wmi_plus.pl -H 192.168.1.15 -u 'user' -p 'password' -m checkservice -a 'MSSQL\$INSTANCE'
OUTPUT: OK - Found 1 Services(s), 1 OK and 0 with problems (0 excluded). 'SQL Server (INSTANCE)' (MSSQL$INSTANCE) is Running.|'Total Service Count'=1; 'Service Count OK State'=1; 'Service Count Problem State'=0; 'Excluded Service Count'=0;
Noticed that it put the "\" character in the command even when I used the arguement: -a 'MSSQL$INSTANCE'. This is fine but once I apply configuration and check the host, I am seeing the following status message

Code: Select all

OK - Found 0 Services(s), 0 OK and 0 with problems (0 excluded).
I've had ran into similar problem with Core, but I was able to get it to recognize the $ sign. I am not sure what's required in XI in order for this to check the SQL service properly?

Thanks in advance.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: WMI Servicecheck SQL instance - special character

Post by abrist »

The dollar sign needs to be escaped in the arg with one of the two following examples (depending on the plugin):

Code: Select all

MSSQL\$INSTANCE
Or:

Code: Select all

MSSQL$$INSTANCE
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
OptimusB
Posts: 146
Joined: Mon Oct 27, 2014 10:08 pm
Location: Canada
Contact:

Re: WMI Servicecheck SQL instance - special character

Post by OptimusB »

Here are the results:

Using "MSSQL$$INSTANCE"

Code: Select all

COMMAND: /usr/local/nagios/libexec/check_wmi_plus.pl -H 192.168.1.15 -u 'user' -p 'password' -m checkservice -a MSSQL\$\$INSTANCE
OUTPUT: OK - Found 0 Services(s), 0 OK and 0 with problems (0 excluded). |'Total Service Count'=0; 'Service Count OK State'=0; 'Service Count Problem State'=0; 'Excluded Service Count'=0;
Using "MSSQL\$INSTANCE"

Code: Select all

COMMAND: /usr/local/nagios/libexec/check_wmi_plus.pl -H 192.168.1.15 -u 'user' -p 'password' -m checkservice -a MSSQL\\\$INSTANCE
OUTPUT: OK - Found 1 Services(s), 1 OK and 0 with problems (0 excluded). 'SQL Server (INSTANCE)' (MSSQL$INSTANCE) is Running.|'Total Service Count'=1; 'Service Count OK State'=1; 'Service Count Problem State'=0; 'Excluded Service Count'=0;
With the second one, I am still only getting "OK - Found 0 Services(s), 0 OK and 0 with problems (0 excluded)." when viewing in the dashboard.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: WMI Servicecheck SQL instance - special character

Post by abrist »

Do not use the "test check command" to verify these escape patterns as the test *adds* escaping. Are you a client? If so, send an email to [email protected] to open a ticket and we will remote in and fix this.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
OptimusB
Posts: 146
Joined: Mon Oct 27, 2014 10:08 pm
Location: Canada
Contact:

Re: WMI Servicecheck SQL instance - special character

Post by OptimusB »

I am currently putting together a demo for a client to review.
I have tried both suggestions and ignoring the test command results. However in both situations the status of the service check outputs the following as mentioned.

Code: Select all

"OK - Found 0 Services(s), 0 OK and 0 with problems (0 excluded)."
I have a similar setup with Core for a SQL Express instance "MSSQL$INSTANCE". However in that scenario I am using check_NT with NSClient++ and my check command is format as such in the cfg. I've tried this with the XI setup, but could not get it to work.

Code: Select all

check_command           check_nt!SERVICESTATE!-d SHOWALL -l MSSQL"$$"CORPBC
OptimusB
Posts: 146
Joined: Mon Oct 27, 2014 10:08 pm
Location: Canada
Contact:

Re: WMI Servicecheck SQL instance - special character

Post by OptimusB »

Ok. So I was able to fix this issue by going into the CFG file of the service and manually editing the check command.

Code: Select all

check_command                   check_xi_service_wmiplus!'user'!'password'!checkservice!-a 'MSSQL\$INSTANCE'!!!!
By default, no matter what I do within XI CCM, this will NOT put that into the CFG file. (I checked the file after each suggest edit from above)

I finally got the result I wanted in the dashboard.

Code: Select all

OK - Found 1 Services(s), 1 OK and 0 with problems (0 excluded). 'SQL Server (VIM_SQLEXP)' (MSSQL$INSTANCE) is Running
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: WMI Servicecheck SQL instance - special character

Post by lmiltchev »

I am glad your issue has been resolved! I am locking this topic. If you have any more questions/issues, please start a new thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked