Unable to get performance metrics from check_sql

I have a query in CEE that which returns back exactly the numeric value that I want but it isn’t returning any performance data (I do have the option enabled in the rule).

The query is for a postgresql database and it’s structured like this:

SELECT SUM(highly_vulnerable_count) from public.bopatchreports

And the value is returned in check_mk like this:

OK - 114: 114.0

From reading the man page on this check, it is said that three columns are returned but I’m not sure how I can debug this to see if this is the case (the three being a number, a text, and optional performance data)

Hey, Refering to the Docs: SQL Database Request Check

The query must return three columns, a number, a text, and optional performance data in the third column. The columns are comma-separated. Performance data must be in the standard format of nagios performance data. If upper and lower levels are given, the number is checked against these levels and the according state is being computed. Otherwise the number ist treated as a Nagios state (0,1,2,3). State, text and the performance data are being returned.

So your query should look something like:
SELECT '0', SUM(highly_vulnerable_count), CONCAT('| highvulncount=',SUM(highly_vulnerable_count)) from public.bopatchreports

The First 0 is for the status output (ok), the second is the “Output of check plugin” and the third is the performance data.

The | was needed in our cases if you have multiple values which should be appear in the performance data.

You, sir, are the man! that worked great. Can you show me an example of what a multi-value query would be? would be good to know in case I decide to consolidate multiple related queries into one.

i’m not 100% sure but it should look like the normal check output as described here: Local checks (look for multiple values)

count1=42|count2=21;23;27|count3=73

so it should be something like (untested):
SELECT '0', SUM(highly_vulnerable_count), CONCAT('| highvulncount=',SUM(highly_vulnerable_count),'|secondvalue=',SUM(secondCount)) from public.bopatchreports

That worked perfectly. Thank you much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.