diff options
| author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-30 00:03:24 +0200 |
|---|---|---|
| committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-30 00:03:24 +0200 |
| commit | 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 (patch) | |
| tree | 1c2b6b21704a294940f87c7892676998d8371707 /web/attachments/411426-check_mysql_query.diff | |
| download | site-0b6423f9c99d9edf8c96fefd0f6c453859395aa1.tar.gz | |
Import Nagios Plugins site
Import the Nagios Plugins web site, Cronjobs, infrastructure scripts,
and configuration files.
Diffstat (limited to 'web/attachments/411426-check_mysql_query.diff')
| -rw-r--r-- | web/attachments/411426-check_mysql_query.diff | 57 |
1 files changed, 57 insertions, 0 deletions
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 @@ | |||
| 1 | --- check_mysql_query.c 2010-07-27 22:47:16.000000000 +0200 | ||
| 2 | +++ /home/psy/check_mysql_query_psy.c 2011-05-12 17:01:19.000000000 +0200 | ||
| 3 | @@ -67,8 +67,9 @@ | ||
| 4 | MYSQL_ROW row; | ||
| 5 | |||
| 6 | double value; | ||
| 7 | + char perfmin[20],perfmax[20]; | ||
| 8 | char *error = NULL; | ||
| 9 | - int status; | ||
| 10 | + int status,cols; | ||
| 11 | |||
| 12 | setlocale (LC_ALL, ""); | ||
| 13 | bindtextdomain (PACKAGE, LOCALEDIR); | ||
| 14 | @@ -128,6 +129,7 @@ | ||
| 15 | die (STATE_CRITICAL, "QUERY %s: Fetch row error - %s\n", _("CRITICAL"), error); | ||
| 16 | } | ||
| 17 | |||
| 18 | + cols = mysql_num_fields(res); | ||
| 19 | /* free the result */ | ||
| 20 | mysql_free_result (res); | ||
| 21 | |||
| 22 | @@ -140,20 +142,31 @@ | ||
| 23 | |||
| 24 | value = strtod(row[0], NULL); | ||
| 25 | |||
| 26 | + if ( (cols >= 2) && (is_numeric(row[1])) ) | ||
| 27 | + sprintf(perfmin,"%g",strtod(row[1],NULL)); | ||
| 28 | + else | ||
| 29 | + sprintf(perfmin, ""); | ||
| 30 | + | ||
| 31 | + if ( (cols >= 3) && (is_numeric(row[2])) ) | ||
| 32 | + sprintf(perfmax,"%g",strtod(row[2],NULL)); | ||
| 33 | + else | ||
| 34 | + sprintf(perfmax, ""); | ||
| 35 | + | ||
| 36 | if (verbose >= 3) | ||
| 37 | printf("mysql result: %f\n", value); | ||
| 38 | |||
| 39 | status = get_status(value, my_thresholds); | ||
| 40 | |||
| 41 | if (status == STATE_OK) { | ||
| 42 | - printf("QUERY %s: ", _("OK")); | ||
| 43 | + printf("QUERY %s: returned %g", _("OK"),value); | ||
| 44 | } else if (status == STATE_WARNING) { | ||
| 45 | - printf("QUERY %s: ", _("WARNING")); | ||
| 46 | + printf("QUERY %s: returned %g", _("WARNING"),value); | ||
| 47 | } else if (status == STATE_CRITICAL) { | ||
| 48 | - printf("QUERY %s: ", _("CRITICAL")); | ||
| 49 | + printf("QUERY %s: returned %g", _("CRITICAL"),value); | ||
| 50 | } | ||
| 51 | - printf(_("'%s' returned %f"), sql_query, value); | ||
| 52 | printf("\n"); | ||
| 53 | + printf(_("'%s'\n"), sql_query); | ||
| 54 | + printf("| value=%g;;;%s;%s\n",value,perfmin,perfmax); | ||
| 55 | |||
| 56 | return status; | ||
| 57 | } | ||
