[Nagiosplug-devel] check_mysql_query plugin can not call stored procedures -- fix suggested

Cook, Malcolm MEC at Stowers-Institute.org
Wed Oct 15 16:00:44 CEST 2008


I find that the check_mysql_query (nagios-plugins 1.4.9) 1.6 can not be used to call stored procedures

When I try, I get an error

viz.

/usr/lib/nagios/plugins/check_mysql_query -q 'call sp_nagios_check()' -w 0:0 -c 1 --hostname=myhost --database=mydb --username=nagios --password=nagios
QUERY CRITICAL: Error with query - PROCEDURE limsdevbuild.sp_nagios_check can't return a result set in the given context


The fix is to fix the call to mysql_real_connect()<http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html> http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html, which states

If your program uses the CALL SQL statement to execute stored procedures that produce result sets, you must set the CLIENT_MULTI_RESULTS flag, either explicitly, or implicitly by setting CLIENT_MULTI_STATEMENTS when you call mysql_real_connect()<http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html>. This is because each such stored procedure produces multiple results: the result sets returned by statements executed within the procedure, as well as a result to indicate the call status.

If you enable CLIENT_MULTI_STATEMENTS or CLIENT_MULTI_RESULTS, you should process the result for every call to mysql_query()<http://dev.mysql.com/doc/refman/5.0/en/mysql-query.html> or mysql_real_query()<http://dev.mysql.com/doc/refman/5.0/en/mysql-real-query.html> by using a loop that calls mysql_next_result()<http://dev.mysql.com/doc/refman/5.0/en/mysql-next-result.html> to determine whether there are more results. For an example, see Section 19.7.9, "C API Handling of Multiple Statement Execution"<http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html>.

Any chance a patch can be issued?

Also, can a new version of the plugin co-exist with an old version of nagios (Nagios 2.7)?


Thanks!

Malcolm Cook
Database Applications Manager - Bioinformatics
Stowers Institute for Medical Research - Kansas City, Missouri





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20081015/47b5021e/attachment.html>


More information about the Devel mailing list