aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Tim Laszlo <tim.laszlo@gmail.com> 2012-08-03 15:12:55 -0500
committerGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2013-08-18 18:38:10 +0200
commit1627cdb46af9c7b179e82eb4b5bb0097250ff033 (patch)
tree313bf92a4c56bee457674c11db4a3da3b59c871c
parent33d8bef86ee8d80219d977c1cebc2e8a0fa43476 (diff)
downloadmonitoring-plugins-1627cdb46af9c7b179e82eb4b5bb0097250ff033.tar.gz
check_mysql: when checking slave thread add performance data for seconds behind master
-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;
int check_slave = 0, warn_sec = 0, crit_sec = 0;
int verbose = 0;
+static double warning_time = 0;
+static double critical_time = 0;
+
thresholds *my_threshold = NULL;
int process_arguments (int, char **);
@@ -79,6 +82,7 @@ main (int argc, char **argv)
char *result = NULL;
char *error = NULL;
char slaveresult[SLAVERESULTSIZE];
+ char* slaveperfdata = NULL;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
@@ -218,11 +222,17 @@ main (int argc, char **argv)
status = get_status(value, my_threshold);
+ slaveperfdata = fperfdata ("seconds behind master", value, "s",
+ TRUE, (double) warning_time,
+ TRUE, (double) critical_time,
+ FALSE, 0,
+ FALSE, 0);
+
if (status == STATE_WARNING) {
- printf("SLOW_SLAVE %s: %s\n", _("WARNING"), slaveresult);
+ printf("SLOW_SLAVE %s: %s|%s\n", _("WARNING"), slaveresult, slaveperfdata);
exit(STATE_WARNING);
} else if (status == STATE_CRITICAL) {
- printf("SLOW_SLAVE %s: %s\n", _("CRITICAL"), slaveresult);
+ printf("SLOW_SLAVE %s: %s|%s\n", _("CRITICAL"), slaveresult, slaveperfdata);
exit(STATE_CRITICAL);
}
}
@@ -236,7 +246,9 @@ main (int argc, char **argv)
mysql_close (&mysql);
/* print out the result of stats */
- if (check_slave) {
+ if (check_slave && slaveperfdata) {
+ printf ("%s %s|%s\n", result, slaveresult, slaveperfdata);
+ } else if (check_slave) {
printf ("%s %s\n", result, slaveresult);
} else {
printf ("%s\n", result);
@@ -339,9 +351,11 @@ process_arguments (int argc, char **argv)
break;
case 'w':
warning = optarg;
+ warning_time = strtod (warning, NULL);
break;
case 'c':
critical = optarg;
+ critical_time = strtod (critical, NULL);
break;
case 'V': /* version */
print_revision (progname, NP_VERSION);