summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 446b89f)
raw | patch | inline | side by side (parent: 446b89f)
author | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Sat, 5 Jan 2008 01:06:36 +0000 (01:06 +0000) | ||
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Sat, 5 Jan 2008 01:06:36 +0000 (01:06 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1886 f882894a-f735-0410-b71e-b25c423dba1c
NEWS | patch | blob | history | |
THANKS.in | patch | blob | history | |
plugins/check_dns.c | patch | blob | history |
index 8efceba1e82426c0411dd4928e57c8bdfb82c6ba..485693afe23116bd0dd1642182b2837ab74ecec8 100644 (file)
--- a/NEWS
+++ b/NEWS
Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren)
check_tcp now returns UNKNOWN with invalid hostname
New check_icmp -s option to specify the source IP address
+ check_dns now sorts addresses for testing results for more than one returned IP (Matthias Urlichs)
1.4.11 13th December 2007
Fixed check_http regression in 1.4.10 where following redirects to
diff --git a/THANKS.in b/THANKS.in
index 36ae0b9fa410a2d9fd7067d62135b2f2d66bfc45..abec771d03723ccdaae1136bc2e48630d3456c34 100644 (file)
--- a/THANKS.in
+++ b/THANKS.in
Tom Payerle
Alessandro Ren
Harald Jenny
+Matthias Urlichs
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 454f813b30c0bda831874013a4fb30322468abd7..8ae48cd4fe94cc687f4d090f749f5f54854121f5 100644 (file)
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
int expect_authority = FALSE;
thresholds *time_thresholds = NULL;
+static int
+qstrcmp(const void *p1, const void *p2)
+{
+ /* The actual arguments to this function are "pointers to
+ pointers to char", but strcmp() arguments are "pointers
+ to char", hence the following cast plus dereference */
+ return strcmp(* (char * const *) p1, * (char * const *) p2);
+}
+
+
int
main (int argc, char **argv)
{
char *command_line = NULL;
char input_buffer[MAX_INPUT_BUFFER];
char *address = NULL;
+ char **addresses = NULL;
+ int n_addresses = 0;
char *msg = NULL;
char *temp_buffer = NULL;
int non_authoritative = FALSE;
NSLOOKUP_COMMAND);
}
- if (address == NULL)
- address = strdup (temp_buffer);
- else
- asprintf(&address, "%s,%s", address, temp_buffer);
+ if (addresses == NULL)
+ addresses = malloc(sizeof(*addresses)*10);
+ else if (!(n_addresses % 10))
+ addresses = realloc(addresses,sizeof(*addresses) * (n_addresses + 10));
+ addresses[n_addresses++] = strdup(temp_buffer);
}
-
else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) {
non_authoritative = TRUE;
}
+
result = error_scan (chld_out.line[i]);
if (result != STATE_OK) {
msg = strchr (chld_out.line[i], ':');
}
}
- /* If we got here, we should have an address string,
- * and we can segfault if we do not */
- if (address==NULL || strlen(address)==0)
+ if (addresses) {
+ int i,slen;
+ char *adrp;
+ qsort(addresses, n_addresses, sizeof(*addresses), qstrcmp);
+ for(i=0, slen=1; i < n_addresses; i++) {
+ slen += strlen(addresses[i])+1;
+ }
+ adrp = address = malloc(slen);
+ for(i=0; i < n_addresses; i++) {
+ if (i) *adrp++ = ',';
+ strcpy(adrp, addresses[i]);
+ adrp += strlen(addresses[i]);
+ }
+ *adrp = 0;
+ } else
die (STATE_CRITICAL,
_("DNS CRITICAL - '%s' msg parsing exited with no address\n"),
NSLOOKUP_COMMAND);
printf (" %s\n", _("Optional DNS server you want to use for the lookup"));
printf (" -a, --expected-address=IP-ADDRESS|HOST\n");
printf (" %s\n", _("Optional IP-ADDRESS you expect the DNS server to return. HOST must end with ."));
+ printf (" %s\n", _("Multiple addresses can be separated with commas, and need to be sorted."));
printf (" -A, --expect-authority\n");
printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup"));
printf (" -w, --warning=seconds\n");