Page 1 of 1

Change computed0 to Custom Value

Posted: Thu Jun 27, 2019 6:06 pm
by johnwcos
Hi All,

I am using the mssql plugin to generate a database query to return a single value, it is working fine. I would like to know how to customise the returned field name so it does not display as computed0 - which does not mean much. Can it be changed to a custom value such as "# Widgets" ?

/usr/local/nagios/libexec/check_mssql -H 192.168.0.226 --username "x" --password "y" --database COSDB --port 1433 --query "Select x from dbo.table" --result "Expected Result" --decode --warning 100000 --critical 250000 --querywarning 100000 --querycritical 250000 --result "Expected Result"
OK: Query duration=1.508998 seconds. Query result=68256|query_duration=1.508998s;100000;250000 'computed0'=68256;100000;250000

Re: Change computed0 to Custom Value

Posted: Fri Jun 28, 2019 11:27 am
by lmiltchev
If you changed the column name, it *should* work. Looking at the plugin, it seems like it is grabbing the column name from the query you are running so if you use 'AS' in the mssql query (SELECT x AS columname) and the column header changes it should change the name of computed0.

Example:

Code: Select all

/usr/local/nagios/libexec/check_mssql -H 192.168.0.226 --username "x" --password "y" --database COSDB --port 1433 --query "SELECT COUNT(*) AS '# Widgets' FROM dbo.table" -result "Expected Result" --decode --warning 100000 --critical 250000 --querywarning 100000 --querycritical 250000 --result "Expected Result"

Re: Change computed0 to Custom Value

Posted: Mon Jul 01, 2019 1:34 am
by johnwcos
Perfect, Thanks for the info - SImple.


John

Re: Change computed0 to Custom Value

Posted: Mon Jul 01, 2019 7:08 am
by scottwilkerson
johnwcos wrote:Perfect, Thanks for the info - SImple.


John
Glad to help.

Locking thread