summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0505e9f)
raw | patch | inline | side by side (parent: 0505e9f)
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Mon, 7 Oct 2002 19:05:24 +0000 (19:05 +0000) | ||
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Mon, 7 Oct 2002 19:05:24 +0000 (19:05 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@109 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_dns.c | patch | blob | history |
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index a0d6e85e5d9b9340e4a4dbe9ed8035c69140769e..bc0400f86195562524614d17b51899c53ee7289a 100644 (file)
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
*
* Notes:
* - Safe popen added by Karl DeBisschop 9-11-99
+ * - expected-address parameter added by Alex Chaffee - 7 Oct 2002
*
- * Command line: CHECK_DNS <query_address> [dns_server]
+ * Command line: (see print_usage)
*
* Description:
*
char dns_server[ADDRESS_LENGTH] = "";
char ptr_server[ADDRESS_LENGTH] = "";
int verbose = FALSE;
+char expected_address[ADDRESS_LENGTH] = "";
+int match_expected_address = FALSE;
int
main (int argc, char **argv)
output = strscpy (output, "nslookup returned error status");
}
+ /* compare to expected address */
+ if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) {
+ result = STATE_CRITICAL;
+ output = ssprintf(output, "expected %s but got %s", expected_address, address);
+ }
+
(void) time (&end_time);
if (result == STATE_OK)
{"hostname", required_argument, 0, 'H'},
{"server", required_argument, 0, 's'},
{"reverse-server", required_argument, 0, 'r'},
+ {"expected-address", required_argument, 0, 'a'},
{0, 0, 0, 0}
};
#endif
while (1) {
#ifdef HAVE_GETOPT_H
- c = getopt_long (argc, argv, "+?hVvt:H:s:r:", long_opts, &opt_index);
+ c = getopt_long (argc, argv, "+?hVvt:H:s:r:a:", long_opts, &opt_index);
#else
- c = getopt (argc, argv, "+?hVvt:H:s:r:");
+ c = getopt (argc, argv, "+?hVvt:H:s:r:a:");
#endif
if (c == -1 || c == EOF)
case 'H':
case 's':
case 'r':
+ case 'a':
i++;
}
terminate (STATE_UNKNOWN, "Input buffer overflow\n");
strcpy (ptr_server, optarg);
break;
+ case 'a': /* expected address */
+ if (is_dotted_quad (optarg) == FALSE) {
+ printf ("Invalid expected address\n\n");
+ print_usage (my_basename (argv[0]));
+ exit (STATE_UNKNOWN);
+ }
+ if (strlen (optarg) >= ADDRESS_LENGTH)
+ terminate (STATE_UNKNOWN, "Input buffer overflow\n");
+ strcpy (expected_address, optarg);
+ match_expected_address = TRUE;
+ break;
}
}
return i;
void
print_usage (char *cmd)
{
- printf ("Usage: %s -H host [-s server] [-t timeout]\n" " %s --help\n"
+ printf ("Usage: %s -H host [-s server] [-a expected-address] [-t timeout]\n" " %s --help\n"
" %s --version\n", cmd, cmd, cmd);
}
" The name or address you want to query\n"
"-s, --server=HOST\n"
" Optional DNS server you want to use for the lookup\n"
+ "-a, --expected-address=IP-ADDRESS\n"
+ " Optional IP address you expect the DNS server to return\n"
"-t, --timeout=INTEGER\n"
" Seconds before connection times out (default: %d)\n"
"-h, --help\n"