From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/411426-check_mysql_query.diff | 57 +++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 web/attachments/411426-check_mysql_query.diff (limited to 'web/attachments/411426-check_mysql_query.diff') diff --git a/web/attachments/411426-check_mysql_query.diff b/web/attachments/411426-check_mysql_query.diff new file mode 100644 index 0000000..c635d34 --- /dev/null +++ b/web/attachments/411426-check_mysql_query.diff @@ -0,0 +1,57 @@ +--- check_mysql_query.c 2010-07-27 22:47:16.000000000 +0200 ++++ /home/psy/check_mysql_query_psy.c 2011-05-12 17:01:19.000000000 +0200 +@@ -67,8 +67,9 @@ + MYSQL_ROW row; + + double value; ++ char perfmin[20],perfmax[20]; + char *error = NULL; +- int status; ++ int status,cols; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); +@@ -128,6 +129,7 @@ + die (STATE_CRITICAL, "QUERY %s: Fetch row error - %s\n", _("CRITICAL"), error); + } + ++ cols = mysql_num_fields(res); + /* free the result */ + mysql_free_result (res); + +@@ -140,20 +142,31 @@ + + value = strtod(row[0], NULL); + ++ if ( (cols >= 2) && (is_numeric(row[1])) ) ++ sprintf(perfmin,"%g",strtod(row[1],NULL)); ++ else ++ sprintf(perfmin, ""); ++ ++ if ( (cols >= 3) && (is_numeric(row[2])) ) ++ sprintf(perfmax,"%g",strtod(row[2],NULL)); ++ else ++ sprintf(perfmax, ""); ++ + if (verbose >= 3) + printf("mysql result: %f\n", value); + + status = get_status(value, my_thresholds); + + if (status == STATE_OK) { +- printf("QUERY %s: ", _("OK")); ++ printf("QUERY %s: returned %g", _("OK"),value); + } else if (status == STATE_WARNING) { +- printf("QUERY %s: ", _("WARNING")); ++ printf("QUERY %s: returned %g", _("WARNING"),value); + } else if (status == STATE_CRITICAL) { +- printf("QUERY %s: ", _("CRITICAL")); ++ printf("QUERY %s: returned %g", _("CRITICAL"),value); + } +- printf(_("'%s' returned %f"), sql_query, value); + printf("\n"); ++ printf(_("'%s'\n"), sql_query); ++ printf("| value=%g;;;%s;%s\n",value,perfmin,perfmax); + + return status; + } -- cgit v1.2.3-74-g34f1