diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 2a3e376028f8f653b9089296c43d1601d64a0c90..3b94a7abd87f6e8a6e17623c435f5f45c7a3eda6 100644 (file)
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
char expected_address[ADDRESS_LENGTH] = "";
int match_expected_address = FALSE;
int expect_authority = FALSE;
+thresholds *time_thresholds = NULL;
int
main (int argc, char **argv)
else
multi_address = TRUE;
- printf ("DNS %s: ", _("OK"));
+ result = get_status(elapsed_time, time_thresholds);
+ if (result == STATE_OK) {
+ printf ("DNS %s: ", _("OK"));
+ } else if (result == STATE_WARNING) {
+ printf ("DNS %s: ", _("WARNING"));
+ } else if (result == STATE_CRITICAL) {
+ printf ("DNS %s: ", _("CRITICAL"));
+ }
printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time);
printf (_(". %s returns %s"), query_address, address);
printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
process_arguments (int argc, char **argv)
{
int c;
+ char *warning = NULL;
+ char *critical = NULL;
int opt_index = 0;
static struct option long_opts[] = {
{"reverse-server", required_argument, 0, 'r'},
{"expected-address", required_argument, 0, 'a'},
{"expect-authority", no_argument, 0, 'A'},
+ {"warning", no_argument, 0, 'w'},
+ {"critical", no_argument, 0, 'c'},
{0, 0, 0, 0}
};
strcpy (argv[c], "-t");
while (1) {
- c = getopt_long (argc, argv, "hVvAt:H:s:r:a:", long_opts, &opt_index);
+ c = getopt_long (argc, argv, "hVvAt:H:s:r:a:w:c:", long_opts, &opt_index);
if (c == -1 || c == EOF)
break;
case 'A': /* expect authority */
expect_authority = TRUE;
break;
+ case 'w':
+ warning = optarg;
+ break;
+ case 'c':
+ critical = optarg;
+ break;
default: /* args not parsable */
usage_va(_("Unknown argument - %s"), optarg);
}
strcpy (dns_server, argv[c++]);
}
+ set_thresholds(&time_thresholds, warning, critical);
+
return validate_arguments ();
}
printf (" %s\n", _("Optional IP-ADDRESS you expect the DNS server to return. HOST must end with ."));
printf (" -A, --expect-authority\n");
printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup"));
+ printf (" -w, --warning=seconds\n");
+ printf (" %s\n", _("Return warning if elapsed time exceeds value. Default off"));
+ printf (" -c, --critical=seconds\n");
+ printf (" %s\n", _("Return critical if elapsed time exceeds value. Default off"));
printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
printf (_(UT_SUPPORT));
{
printf (_("Usage:"));
- printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout]\n", progname);
+ printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit]\n", progname);
}