1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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;
}
|