Page 2 of 2

Re: MSSQL check that will return query value as perf data

Posted: Fri Jun 20, 2014 1:51 pm
by tmcdonald
Looks like the plugin itself does not give performance data for the actual query result, and this makes sense given that many SQL queries will return a whole row which doesn't fit well into perfdata. Making the change will require an edit to the plugin. It's a relatively short PHP plugin so I can probably tackle this here, though actually getting that perfdata in the graph is another story.

Can you run the command manually from the CLI and post the output? I want to see if there is anything in your output we can use in the perfdata.

Re: MSSQL check that will return query value as perf data

Posted: Fri Jun 20, 2014 2:24 pm
by lmiltchev
What is the plugin's version that you are using?

Code: Select all

./check_mssql -V

Re: MSSQL check that will return query value as perf data

Posted: Fri Jun 20, 2014 2:34 pm
by vAJ
Here's output from the CLI:

Code: Select all

PHP Notice:  Undefined variable: exit_code in /usr/local/nagios/libexec/check_mssql on line 315
OK: Query duration=0.104882 seconds.|query_duration=0.104882s;1;2;0;

Re: MSSQL check that will return query value as perf data

Posted: Fri Jun 20, 2014 2:36 pm
by vAJ
lmiltchev wrote:What is the plugin's version that you are using?

Code: Select all

./check_mssql -V
0.6.8

Re: MSSQL check that will return query value as perf data

Posted: Mon Jun 23, 2014 10:15 am
by tmcdonald
Can you include the actual command you are running in addition to the output it provides? That notice about the undefined variable is a bit odd. But it does not look like your query result is included either in the output or in the performance data. I can take a look at it but not being a developer there is only so much I can do.

Re: MSSQL check that will return query value as perf data

Posted: Mon Jun 23, 2014 10:20 am
by vAJ
Command is on page one of this thread. Is that not what you need?

Re: MSSQL check that will return query value as perf data

Posted: Mon Jun 23, 2014 10:31 am
by tmcdonald
I just wanted to make sure that the output you posted above is indeed the result of that command, so it helps to see them together on one page. But yes, that is what I was looking for. Let me poke around the code a bit and see what I can find. I might ask you to test out a few changes to make sure they are working properly for you.

ADD: So it looks like the $query_result holds the result of the SQL query, so if you know it will be a consistent format (always a decimal, always a lower-case string, etc.) you can modify the perfdata like so (line 347):

Code: Select all

$perfdata = "query_duration={$query_duration}s;{$warning};{$critical};0;query_result={$query_result};";
Bear in mind that this will likely screw up any existing graphing you have for that service (since it adds new perfdata), so I would create a copy of check_mssql specifically for the checks that need this result.

Let me know how this works out.

Re: MSSQL check that will return query value as perf data

Posted: Sat Aug 02, 2014 11:20 pm
by reinaldo.gomes
Speaking of check_mssql, is there a reason for blocking underlines at the username, like in "user_name" ?
I was getting an annyoing "invalid characters in the username" until I edited the code and added a simple "\_" to the username's regex.
Will there be any downside to it?

Re: MSSQL check that will return query value as perf data

Posted: Mon Aug 04, 2014 4:27 pm
by tmcdonald
I can't say for sure if there would be any downsides, but underscores aren't particularly special in SQL queries or bash so I don't see why it would be a concern.