}
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 */
asprintf(&db_pass, "%s", optarg);
/* Delete the password from process list */
while (*optarg != '\0') {
*optarg = 'X';
optarg++;
}
break;
case 'P': /* critical time threshold */
db_port = atoi (optarg);
break;
case 'v':
verbose++;
break;
case 'V': /* version */
print_revision (progname, revision);
exit (STATE_OK);
case 'h': /* help */
print_help ();
exit (STATE_OK);
case 'q':
asprintf(&sql_query, "%s", optarg);
break;
case 'w':
warning = optarg;
break;
case 'c':
critical = optarg;
break;
case '?': /* help */
usage5 ();
}
}
c = optind;
set_thresholds(&my_thresholds, warning, critical);
return validate_arguments ();
}
int
validate_arguments (void)
{
if (sql_query == NULL)
usage("Must specify a SQL query to run");
if (db_user == NULL)
db_user = strdup("");
if (db_host == NULL)
db_host = strdup("");
if (db_pass == NULL)
db_pass == strdup("");
if (db == NULL)
db = strdup("");
return OK;
}
void
print_help (void)
{
char *myport;
asprintf (&myport, "%d", MYSQL_PORT);
print_revision (progname, revision);
printf (_(COPYRIGHT), copyright, email);
printf ("%s\n", _("This program checks a query result against threshold levels"));
printf ("\n\n");
print_usage ();
printf (_(UT_HELP_VRSN));
printf (" -q, --query=STRING\n");
printf (" %s\n", _("SQL query to run. Only first column in first row will be read"));
printf (_(UT_WARN_CRIT_RANGE));
printf (_(UT_HOST_PORT), 'P', myport);
printf (" -d, --database=STRING\n");
printf (" %s\n", _("Database to check"));
printf (" -u, --username=STRING\n");
=3= |