*** xymonnet/xymonnet.h.orig 2015-10-19 02:18:34.000000000 -0600 --- xymonnet/xymonnet.h 2019-04-01 08:33:13.933599000 -0600 *************** *** 42,48 **** * banner nosslcert | | * certinfo dodns | | * duration dnserror | | ! * badtest ////////// | | * downcount repeattest | | * downstart noconn | | * privdata ----+ noping | | --- 42,48 ---- * banner nosslcert | | * certinfo dodns | | * duration dnserror | | ! * badtest pingerror | | * downcount repeattest | | * downstart noconn | | * privdata ----+ noping | | *************** *** 91,96 **** --- 91,97 ---- int hidehttp; /* hidehttp flag */ int dodns; /* set while loading tests if we need to do a DNS lookup */ int dnserror; /* set internally if we cannot find the host's IP */ + int pingerror; /* set internally if host does not answer ping */ int repeattest; /* Set if this host goes on the quick poll list */ char *hosttype; /* For the "Intermediate HOSTTYPE is down" message */ *** xymonnet/xymonnet.c.orig 2016-09-09 21:13:43.000000000 -0600 --- xymonnet/xymonnet.c 2019-04-01 11:00:37.027218000 -0600 *************** *** 107,112 **** --- 107,114 ---- char *defaultsourceip = NULL; int loadhostsfromxymond = 0; int sslminkeysize = 0; + char *warnbuf = NULL; + static unsigned int warnbufsize = 0; void dump_hostlist(void) { *************** *** 876,884 **** --- 878,900 ---- /* Already have the IP setup */ } else { + char msg[512]; /* Cannot resolve hostname */ h->dnserror = 1; + /* Make this a warning rather than an error errprintf("xymonnet: Cannot resolve IP for host %s\n", h->hostname); + */ + sprintf(msg, "xymonnet: Cannot resolve IP for host %s\n", h->hostname); + if (warnbuf == NULL) { + warnbufsize = 8192; + warnbuf = (char *) malloc(warnbufsize); + *warnbuf = '\0'; + } + else if ((strlen(warnbuf) + strlen(msg)) > warnbufsize) { + warnbufsize += 8192; + warnbuf = (char *) realloc(warnbuf, warnbufsize); + } + strcat(warnbuf, msg); } } *************** *** 1066,1072 **** strcpy(cmdpath, (use_sntp ? xgetenv("SNTP") : xgetenv("NTPDATE")) ); for (t=service->items; (t); t = t->next) { ! if (!t->host->dnserror) { if (use_sntp) { sprintf(cmd, "%s %s -d %d %s 2>&1", cmdpath, xgetenv("SNTPOPTS"), extcmdtimeout-1, ip_to_test(t->host)); } --- 1082,1089 ---- strcpy(cmdpath, (use_sntp ? xgetenv("SNTP") : xgetenv("NTPDATE")) ); for (t=service->items; (t); t = t->next) { ! /* Do not run NTP test if host does not resolve in DNS or is down */ ! if (!t->host->dnserror && !t->host->pingerror) { if (use_sntp) { sprintf(cmd, "%s %s -d %d %s 2>&1", cmdpath, xgetenv("SNTPOPTS"), extcmdtimeout-1, ip_to_test(t->host)); } *************** *** 1090,1096 **** p = xgetenv("RPCINFO"); strcpy(cmdpath, (p ? p : "rpcinfo")); for (t=service->items; (t); t = t->next) { ! if (!t->host->dnserror && (t->host->downcount == 0)) { sprintf(cmd, "%s -p %s 2>&1", cmdpath, ip_to_test(t->host)); t->open = (run_command(cmd, NULL, t->banner, 1, extcmdtimeout) == 0); } --- 1107,1114 ---- p = xgetenv("RPCINFO"); strcpy(cmdpath, (p ? p : "rpcinfo")); for (t=service->items; (t); t = t->next) { ! /* Do not run RPCINFO test if host does not resolve in DNS or is down */ ! if (!t->host->dnserror && (t->host->downcount == 0) && !t->host->pingerror) { sprintf(cmd, "%s -p %s 2>&1", cmdpath, ip_to_test(t->host)); t->open = (run_command(cmd, NULL, t->banner, 1, extcmdtimeout) == 0); } *************** *** 1467,1472 **** --- 1485,1493 ---- color = COL_YELLOW; } + /* Set pingerror for later use by NTP and RPCINFO tests */ + test->host->pingerror = (color == COL_RED ? 1 : 0); + /* Handle "badconn" */ if ((color == COL_RED) && (test->host->downcount < test->host->badconn[2])) { if (test->host->downcount >= test->host->badconn[1]) color = COL_YELLOW; *************** *** 2236,2241 **** --- 2257,2263 ---- printf("Usage: %s [options] [host1 host2 host3 ...]\n", argv[0]); printf("General options:\n"); printf(" --timeout=N : Timeout (in seconds) for service tests\n"); + printf(" --cmdtimeout=N : Timeout for external commands for testing NTP, RPC and traceroute\n"); printf(" --concurrency=N : Number of tests run in parallel\n"); printf(" --dns-timeout=N : DNS lookups timeout and fail after N seconds [30]\n"); printf(" --dns=[only|ip|standard] : How IP's are decided\n"); *************** *** 2605,2610 **** --- 2627,2637 ---- addtostatus(prehtmlquoted(errbuf)); } + if (warnbuf) { + addtostatus("\n\nWarning output:\n"); + addtostatus(prehtmlquoted(warnbuf)); + } + show_timestamps(×tamps); addtostatus(timestamps);