diff options
Diffstat (limited to 'plugins/check_mysql.c')
-rw-r--r-- | plugins/check_mysql.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index ad3d86f..eaad709 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c | |||
@@ -59,6 +59,9 @@ unsigned int db_port = MYSQL_PORT; | |||
59 | int check_slave = 0, warn_sec = 0, crit_sec = 0; | 59 | int check_slave = 0, warn_sec = 0, crit_sec = 0; |
60 | int verbose = 0; | 60 | int verbose = 0; |
61 | 61 | ||
62 | static double warning_time = 0; | ||
63 | static double critical_time = 0; | ||
64 | |||
62 | thresholds *my_threshold = NULL; | 65 | thresholds *my_threshold = NULL; |
63 | 66 | ||
64 | int process_arguments (int, char **); | 67 | int 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); |