MSSQL check that will return query value as perf data
Re: MSSQL check that will return query value as perf data
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.
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.
Former Nagios employee
Re: MSSQL check that will return query value as perf data
What is the plugin's version that you are using?
Code: Select all
./check_mssql -V
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: MSSQL check that will return query value as perf data
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;
Andrew J. - Do you even grok?
Re: MSSQL check that will return query value as perf data
0.6.8lmiltchev wrote:What is the plugin's version that you are using?
Code: Select all
./check_mssql -V
Andrew J. - Do you even grok?
Re: MSSQL check that will return query value as perf data
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.
Former Nagios employee
Re: MSSQL check that will return query value as perf data
Command is on page one of this thread. Is that not what you need?
Andrew J. - Do you even grok?
Re: MSSQL check that will return query value as perf data
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):
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.
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};";
Let me know how this works out.
Former Nagios employee
-
- Posts: 59
- Joined: Wed Apr 02, 2014 9:29 am
Re: MSSQL check that will return query value as perf data
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?
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
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.
Former Nagios employee