summaryrefslogtreecommitdiffstats
path: root/plugins/check_mysql.c
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2012-08-03 15:12:55 -0500
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-08-18 18:38:10 +0200
commit1627cdb46af9c7b179e82eb4b5bb0097250ff033 (patch)
tree313bf92a4c56bee457674c11db4a3da3b59c871c /plugins/check_mysql.c
parent33d8bef86ee8d80219d977c1cebc2e8a0fa43476 (diff)
downloadmonitoring-plugins-1627cdb46af9c7b179e82eb4b5bb0097250ff033.tar.gz
check_mysql: when checking slave thread add performance data for seconds behind master
Diffstat (limited to 'plugins/check_mysql.c')
-rw-r--r--plugins/check_mysql.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index ad3d86f3..eaad709f 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -59,6 +59,9 @@ unsigned int db_port = MYSQL_PORT;
59int check_slave = 0, warn_sec = 0, crit_sec = 0; 59int check_slave = 0, warn_sec = 0, crit_sec = 0;
60int verbose = 0; 60int verbose = 0;
61 61
62static double warning_time = 0;
63static double critical_time = 0;
64
62thresholds *my_threshold = NULL; 65thresholds *my_threshold = NULL;
63 66
64int process_arguments (int, char **); 67int process_arguments (int, char **);
@@ -79,6 +82,7 @@ main (int argc, char **argv)
79 char *result = NULL; 82 char *result = NULL;
80 char *error = NULL; 83 char *error = NULL;
81 char slaveresult[SLAVERESULTSIZE]; 84 char slaveresult[SLAVERESULTSIZE];
85 char* slaveperfdata = NULL;
82 86
83 setlocale (LC_ALL, ""); 87 setlocale (LC_ALL, "");
84 bindtextdomain (PACKAGE, LOCALEDIR); 88 bindtextdomain (PACKAGE, LOCALEDIR);
@@ -218,11 +222,17 @@ main (int argc, char **argv)
218 222
219 status = get_status(value, my_threshold); 223 status = get_status(value, my_threshold);
220 224
225 slaveperfdata = fperfdata ("seconds behind master", value, "s",
226 TRUE, (double) warning_time,
227 TRUE, (double) critical_time,
228 FALSE, 0,
229 FALSE, 0);
230
221 if (status == STATE_WARNING) { 231 if (status == STATE_WARNING) {
222 printf("SLOW_SLAVE %s: %s\n", _("WARNING"), slaveresult); 232 printf("SLOW_SLAVE %s: %s|%s\n", _("WARNING"), slaveresult, slaveperfdata);
223 exit(STATE_WARNING); 233 exit(STATE_WARNING);
224 } else if (status == STATE_CRITICAL) { 234 } else if (status == STATE_CRITICAL) {
225 printf("SLOW_SLAVE %s: %s\n", _("CRITICAL"), slaveresult); 235 printf("SLOW_SLAVE %s: %s|%s\n", _("CRITICAL"), slaveresult, slaveperfdata);
226 exit(STATE_CRITICAL); 236 exit(STATE_CRITICAL);
227 } 237 }
228 } 238 }
@@ -236,7 +246,9 @@ main (int argc, char **argv)
236 mysql_close (&mysql); 246 mysql_close (&mysql);
237 247
238 /* print out the result of stats */ 248 /* print out the result of stats */
239 if (check_slave) { 249 if (check_slave && slaveperfdata) {
250 printf ("%s %s|%s\n", result, slaveresult, slaveperfdata);
251 } else if (check_slave) {
240 printf ("%s %s\n", result, slaveresult); 252 printf ("%s %s\n", result, slaveresult);
241 } else { 253 } else {
242 printf ("%s\n", result); 254 printf ("%s\n", result);
@@ -339,9 +351,11 @@ process_arguments (int argc, char **argv)
339 break; 351 break;
340 case 'w': 352 case 'w':
341 warning = optarg; 353 warning = optarg;
354 warning_time = strtod (warning, NULL);
342 break; 355 break;
343 case 'c': 356 case 'c':
344 critical = optarg; 357 critical = optarg;
358 critical_time = strtod (critical, NULL);
345 break; 359 break;
346 case 'V': /* version */ 360 case 'V': /* version */
347 print_revision (progname, NP_VERSION); 361 print_revision (progname, NP_VERSION);