|
@@ -59,6 +59,9 @@ unsigned int db_port = MYSQL_PORT;
|
|
|
int check_slave = 0, warn_sec = 0, crit_sec = 0;
|
|
int check_slave = 0, warn_sec = 0, crit_sec = 0;
|
|
|
int verbose = 0;
|
|
int verbose = 0;
|
|
|
|
|
|
|
|
|
|
+static double warning_time = 0;
|
|
|
|
|
+static double critical_time = 0;
|
|
|
|
|
+
|
|
|
thresholds *my_threshold = NULL;
|
|
thresholds *my_threshold = NULL;
|
|
|
|
|
|
|
|
int process_arguments (int, char **);
|
|
int process_arguments (int, char **);
|
|
@@ -79,6 +82,7 @@ main (int argc, char **argv)
|
|
|
char *result = NULL;
|
|
char *result = NULL;
|
|
|
char *error = NULL;
|
|
char *error = NULL;
|
|
|
char slaveresult[SLAVERESULTSIZE];
|
|
char slaveresult[SLAVERESULTSIZE];
|
|
|
|
|
+ char* slaveperfdata = NULL;
|
|
|
|
|
|
|
|
setlocale (LC_ALL, "");
|
|
setlocale (LC_ALL, "");
|
|
|
bindtextdomain (PACKAGE, LOCALEDIR);
|
|
bindtextdomain (PACKAGE, LOCALEDIR);
|
|
@@ -218,11 +222,17 @@ main (int argc, char **argv)
|
|
|
|
|
|
|
|
status = get_status(value, my_threshold);
|
|
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) {
|
|
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);
|
|
exit(STATE_WARNING);
|
|
|
} else if (status == STATE_CRITICAL) {
|
|
} 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);
|
|
exit(STATE_CRITICAL);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -236,7 +246,9 @@ main (int argc, char **argv)
|
|
|
mysql_close (&mysql);
|
|
mysql_close (&mysql);
|
|
|
|
|
|
|
|
/* print out the result of stats */
|
|
/* 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);
|
|
printf ("%s %s\n", result, slaveresult);
|
|
|
} else {
|
|
} else {
|
|
|
printf ("%s\n", result);
|
|
printf ("%s\n", result);
|
|
@@ -339,9 +351,11 @@ process_arguments (int argc, char **argv)
|
|
|
break;
|
|
break;
|
|
|
case 'w':
|
|
case 'w':
|
|
|
warning = optarg;
|
|
warning = optarg;
|
|
|
|
|
+ warning_time = strtod (warning, NULL);
|
|
|
break;
|
|
break;
|
|
|
case 'c':
|
|
case 'c':
|
|
|
critical = optarg;
|
|
critical = optarg;
|
|
|
|
|
+ critical_time = strtod (critical, NULL);
|
|
|
break;
|
|
break;
|
|
|
case 'V': /* version */
|
|
case 'V': /* version */
|
|
|
print_revision (progname, NP_VERSION);
|
|
print_revision (progname, NP_VERSION);
|