}
}
if ((seconds_behind_field != -1) && (strcmp (row[seconds_behind_field], "NULL") != 0)) {
double value = atof(row[seconds_behind_field]);
int status;
status = get_status(value, my_threshold);
if (status == STATE_WARNING) {
printf("SLOW_SLAVE %s: %s\n", _("WARNING"), slaveresult);
exit(STATE_WARNING);
} else if (status == STATE_CRITICAL) {
printf("SLOW_SLAVE %s: %s\n", _("CRITICAL"), slaveresult);
exit(STATE_CRITICAL);
}
}
}
/* free the result */
mysql_free_result (res);
}
/* close the connection */
mysql_close (&mysql);
/* print out the result of stats */
if (check_slave) {
printf ("%s %s\n", result, slaveresult);
} else {
printf ("%s\n", result);
}
return STATE_OK;
}
/* process command-line arguments */
int
process_arguments (int argc, char **argv)
{
int c;
char *warning = NULL;
char *critical = NULL;
int option = 0;
static struct option longopts[] = {
{"hostname", required_argument, 0, 'H'},
{"database", required_argument, 0, 'd'},
{"username", required_argument, 0, 'u'},
{"password", required_argument, 0, 'p'},
{"port", required_argument, 0, 'P'},
{"critical", required_argument, 0, 'c'},
{"warning", required_argument, 0, 'w'},
{"check-slave", no_argument, 0, 'S'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
if (argc < 1)
return ERROR;
while (1) {
c = getopt_long (argc, argv, "hvVSP:p:u:d:H:c:w:", longopts, &option);
if (c == -1 || c == EOF)
break;
switch (c) {
case 'H': /* hostname */
if (is_host (optarg)) {
db_host = optarg;
}
else {
usage2 (_("Invalid hostname/address"), optarg);
}
break;
case 'd': /* hostname */
db = optarg;
break;
case 'u': /* username */
db_user = optarg;
break;
case 'p': /* authentication information: password */
db_pass = optarg;
break;
case 'P': /* critical time threshold */
db_port = atoi (optarg);
break;
case 'S':
check_slave = 1; /* check-slave */
break;
case 'w':
warning = optarg;
break;
case 'c':
critical = optarg;
break;
=3= |