Skip to content
This repository has been archived by the owner on Jan 30, 2021. It is now read-only.

Commit

Permalink
Additional reporting (info.html and textinfo.html) for dns address re…
Browse files Browse the repository at this point in the history
…solution.

Instead of just a (current) queued value, reports "Current Queue", "Maximum Queue"
and "Total Queued".  These give you visibility into whether DNS resolution is
bogging down.

Removed "dropped" - it was being reported but no code to count it.

Added "DNS responses sniffed" - this is the count of how many DNS resolutions
have been sniffed out of other people's DNS responses that ntop has processed.

    Note that this is the # of responses, NOT the # of UNIQUE addresses.
    If you have a host that keeps requesting the same address, it will
    be counted each time!

Finally, cleaned up the #ifdef ASYNC_ADDRESS_RESOLUTION stuff.

-----Burton (ref 142)
  • Loading branch information
burton committed Oct 16, 2002
1 parent 7777544 commit b9f29ec
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 47 deletions.
11 changes: 6 additions & 5 deletions address.c
Expand Up @@ -59,7 +59,7 @@ void updateHostNameInfo(unsigned long numeric,

/* Search the instance and update its name */

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
accessMutex(&myGlobals.addressResolutionMutex, "updateHostNameInfo");
#endif
Expand All @@ -75,7 +75,7 @@ void updateHostNameInfo(unsigned long numeric,
}
}

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand Down Expand Up @@ -402,6 +402,7 @@ static void queueAddress(struct in_addr elem) {

if (rc == 0) {
myGlobals.addressQueueLen++;
myGlobals.addressQueueCount++;
if (myGlobals.addressQueueLen > myGlobals.maxAddressQueueLen)
myGlobals.maxAddressQueueLen = myGlobals.addressQueueLen;

Expand Down Expand Up @@ -632,10 +633,10 @@ void ipaddr2str(struct in_addr hostIpAddress, int actualDeviceId) {
if(buf[0] != '\0') {
updateHostNameInfo(hostIpAddress.s_addr, buf, actualDeviceId);
} else {
#ifndef MULTITHREADED
resolveAddress(&hostIpAddress, 0, actualDeviceId);
#else
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
queueAddress(hostIpAddress);
#else
resolveAddress(&hostIpAddress, 0, actualDeviceId);
#endif
}
}
Expand Down
1 change: 0 additions & 1 deletion globals-core.c
Expand Up @@ -171,7 +171,6 @@ void initNtopGlobals(int argc, char * argv[]) {
#ifdef ASYNC_ADDRESS_RESOLUTION
for (i = 0; i < MAX_NUM_DEQUEUE_THREADS; i ++)
myGlobals.dequeueAddressThreadId[i] = (pthread_t)-1;
myGlobals.droppedAddresses.value = 0;
#endif

#endif /* MULTITHREADED */
Expand Down
5 changes: 2 additions & 3 deletions globals.h
Expand Up @@ -332,9 +332,6 @@ typedef struct ntopGlobals {

pthread_t handleWebConnectionsThreadId;

#ifdef ASYNC_ADDRESS_RESOLUTION
TrafficCounter droppedAddresses;
#endif
#endif /* MULTITHREADED */

/* SSL support */
Expand Down Expand Up @@ -366,7 +363,9 @@ typedef struct ntopGlobals {
FlowFilterList *flowsList;

/* Address Resolution */
u_long dnsSniffedCount;
#if defined(ASYNC_ADDRESS_RESOLUTION)
u_long addressQueueCount;
u_int addressQueueLen, maxAddressQueueLen;
#endif

Expand Down
7 changes: 6 additions & 1 deletion ntop.c
Expand Up @@ -48,8 +48,10 @@ void handleSigHup(int signalId _UNUSED_) {
printMutexInfo(&myGlobals.gdbmMutex, "myGlobals.gdbmMutex");
printMutexInfo(&myGlobals.packetQueueMutex, "myGlobals.packetQueueMutex");

#ifdef ASYNC_ADDRESS_RESOLUTION
if(myGlobals.numericFlag == 0)
printMutexInfo(&myGlobals.addressResolutionMutex, "myGlobals.addressResolutionMutex");
#endif

if(myGlobals.isLsofPresent)
printMutexInfo(&myGlobals.lsofMutex, "myGlobals.lsofMutex");
Expand Down Expand Up @@ -858,7 +860,10 @@ RETSIGTYPE cleanup(int signo) {

#ifdef MULTITHREADED
deleteMutex(&myGlobals.packetQueueMutex);
if(myGlobals.numericFlag == 0) deleteMutex(&myGlobals.addressResolutionMutex);
#ifdef ASYNC_ADDRESS_RESOLUTION
if(myGlobals.numericFlag == 0)
deleteMutex(&myGlobals.addressResolutionMutex);
#endif
deleteMutex(&myGlobals.hostsHashMutex);
deleteMutex(&myGlobals.graphMutex);

Expand Down
1 change: 1 addition & 0 deletions protocols.c
Expand Up @@ -627,6 +627,7 @@ u_int16_t processDNSPacket(const u_char *packetData,
accessMutex(&myGlobals.gdbmMutex, "processDNSPacket");
#endif
gdbm_store(myGlobals.gdbm_file, key_data, data_data, GDBM_REPLACE);
myGlobals.dnsSniffedCount++;
#ifdef MULTITHREADED
releaseMutex(&myGlobals.gdbmMutex);
#endif
Expand Down
8 changes: 4 additions & 4 deletions report.c
Expand Up @@ -3595,11 +3595,11 @@ static int cmpStatsFctn(const void *_a, const void *_b) {
*/
return(strcasecmp(a->domainHost->fullDomainName, b->domainHost->fullDomainName));
} else {
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) accessMutex(&myGlobals.addressResolutionMutex, "fillDomainName");
#endif
rc = strcasecmp(a->domainHost->hostSymIpAddress, b->domainHost->hostSymIpAddress);
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) releaseMutex(&myGlobals.addressResolutionMutex);
#endif
}
Expand Down Expand Up @@ -3930,7 +3930,7 @@ void printDomainStats(char* domainName, int sortedColumn, int revertOrder, int p
char tmpBuf[64], *hostLink;
int blankId;

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) accessMutex(&myGlobals.addressResolutionMutex, "getHostIcon");
#endif

Expand All @@ -3939,7 +3939,7 @@ void printDomainStats(char* domainName, int sortedColumn, int revertOrder, int p

strncpy(tmpBuf, statsEntry->domainHost->hostSymIpAddress, sizeof(tmpBuf));

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) releaseMutex(&myGlobals.addressResolutionMutex);
#endif

Expand Down
30 changes: 15 additions & 15 deletions reportUtils.c
Expand Up @@ -730,13 +730,13 @@ int sortHostFctn(const void *_a, const void *_b) {

switch(myGlobals.columnSort) {
case 1:
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
accessMutex(&myGlobals.addressResolutionMutex, "sortHostFctn");
#endif
rc = strcasecmp((*a)->hostSymIpAddress[0] != '\0' ? (*a)->hostSymIpAddress : (*a)->ethAddressString,
(*b)->hostSymIpAddress[0] != '\0' ? (*b)->hostSymIpAddress : (*b)->ethAddressString);
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand Down Expand Up @@ -904,7 +904,7 @@ int cmpFctn(const void *_a, const void *_b) {
int rc;

/* Host name */
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
accessMutex(&myGlobals.addressResolutionMutex, "cmpFctn");
#endif
Expand All @@ -919,7 +919,7 @@ int cmpFctn(const void *_a, const void *_b) {
} else
rc = strcasecmp((*a)->ethAddressString, (*b)->ethAddressString);

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand Down Expand Up @@ -1389,14 +1389,14 @@ int cmpMulticastFctn(const void *_a, const void *_b) {
break; /* NOTREACHED */

default:
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
accessMutex(&myGlobals.addressResolutionMutex, "cmpMulticastFctn");
#endif

rc = strcmp((*a)->hostSymIpAddress, /* Host name */
(*b)->hostSymIpAddress);
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand Down Expand Up @@ -1521,7 +1521,7 @@ int cmpHostsFctn(const void *_a, const void *_b) {
break;

default: /* Host Name */
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) accessMutex(&myGlobals.addressResolutionMutex, "cmpHostsFctn");
#endif

Expand All @@ -1545,7 +1545,7 @@ int cmpHostsFctn(const void *_a, const void *_b) {
name_b = (*b)->ethAddressString;
}

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) releaseMutex(&myGlobals.addressResolutionMutex);
#endif

Expand Down Expand Up @@ -2914,7 +2914,7 @@ void printHostDetailedInfo(HostTraffic *el, int actualDeviceId) {
int printedHeader, i;
char *dynIp, *multihomed;

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) accessMutex(&myGlobals.addressResolutionMutex, "printAllSessionsHTML");
#endif

Expand All @@ -2941,7 +2941,7 @@ void printHostDetailedInfo(HostTraffic *el, int actualDeviceId) {
BufferTooShort();
}

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) releaseMutex(&myGlobals.addressResolutionMutex);
#endif

Expand All @@ -2952,18 +2952,18 @@ void printHostDetailedInfo(HostTraffic *el, int actualDeviceId) {
if(el->hostNumIpAddress[0] != '\0') {
char *countryIcon, *hostType;

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) accessMutex(&myGlobals.addressResolutionMutex, "printAllSessions-2");
#endif

/* Courtesy of Roberto De Luca <deluca@tandar.cnea.gov.ar> */
if(strcmp(el->hostNumIpAddress, el->hostSymIpAddress) != 0) {
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) releaseMutex(&myGlobals.addressResolutionMutex);
#endif
countryIcon = getHostCountryIconURL(el);
} else {
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) releaseMutex(&myGlobals.addressResolutionMutex);
#endif
countryIcon = "";
Expand Down Expand Up @@ -3833,7 +3833,7 @@ char* buildHTMLBrowserWindowsLabel(int i, int j) {
static char buf[BUF_SIZE];
int idx = i*myGlobals.device[myGlobals.actualReportDeviceId].numHosts + j;

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
accessMutex(&myGlobals.addressResolutionMutex, "buildHTMLBrowserWindowsLabel");
#endif
Expand Down Expand Up @@ -3871,7 +3871,7 @@ char* buildHTMLBrowserWindowsLabel(int i, int j) {
BufferTooShort();
}

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0) releaseMutex(&myGlobals.addressResolutionMutex);
#endif

Expand Down
8 changes: 4 additions & 4 deletions util.c
Expand Up @@ -2484,7 +2484,7 @@ void fillDomainName(HostTraffic *el) {
|| (el->hostSymIpAddress == NULL))
return;

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
accessMutex(&myGlobals.addressResolutionMutex, "fillDomainName");
#endif
Expand All @@ -2495,7 +2495,7 @@ void fillDomainName(HostTraffic *el) {
isdigit(el->hostSymIpAddress[0]))) {
/* NOTE: theDomainHasBeenComputed(el) = 0 */
el->fullDomainName = el->dotDomainName = "";
#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand Down Expand Up @@ -2541,7 +2541,7 @@ void fillDomainName(HostTraffic *el) {
el->fullDomainName = el->dotDomainName = "";
}

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand All @@ -2564,7 +2564,7 @@ void fillDomainName(HostTraffic *el) {

/* traceEvent(TRACE_INFO, "'%s'\n", el->domainName); */

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand Down
30 changes: 16 additions & 14 deletions webInterface.c
Expand Up @@ -350,7 +350,7 @@ char* makeHostLink(HostTraffic *el, short mode,

bufIdx = (bufIdx+1)%5;

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
accessMutex(&myGlobals.addressResolutionMutex, "makeHostLink");
#endif
Expand All @@ -367,7 +367,7 @@ char* makeHostLink(HostTraffic *el, short mode,
if(snprintf(buf[bufIdx], BUF_SIZE, fmt, el->hostSymIpAddress) < 0)
BufferTooShort();

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand Down Expand Up @@ -404,7 +404,7 @@ char* makeHostLink(HostTraffic *el, short mode,
usedEthAddress = 1;
}

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand Down Expand Up @@ -524,7 +524,7 @@ char* getHostName(HostTraffic *el, short cutName) {

bufIdx = (bufIdx+1)%5;

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
accessMutex(&myGlobals.addressResolutionMutex, "getHostName");
#endif
Expand Down Expand Up @@ -554,7 +554,7 @@ char* getHostName(HostTraffic *el, short cutName) {
} else
strncpy(buf[bufIdx], el->ethAddressString, 80);

#ifdef MULTITHREADED
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
releaseMutex(&myGlobals.addressResolutionMutex);
#endif
Expand Down Expand Up @@ -2467,7 +2467,13 @@ void printNtopConfigInfo(int textPrintFlag) {
if(myGlobals.numericFlag == 0) {
if(snprintf(buf, sizeof(buf), "%d", myGlobals.addressQueueLen) < 0)
BufferTooShort();
printFeatureConfigInfo(textPrintFlag, "Queued", buf);
printFeatureConfigInfo(textPrintFlag, "Current Queue", buf);
if(snprintf(buf, sizeof(buf), "%d", myGlobals.maxAddressQueueLen) < 0)
BufferTooShort();
printFeatureConfigInfo(textPrintFlag, "Maximum Queued", buf);
if(snprintf(buf, sizeof(buf), "%d", myGlobals.addressQueueCount) < 0)
BufferTooShort();
printFeatureConfigInfo(textPrintFlag, "Total Queued", buf);
}
#endif

Expand All @@ -2483,13 +2489,9 @@ void printNtopConfigInfo(int textPrintFlag) {
BufferTooShort();
printFeatureConfigInfo(textPrintFlag, "Found in Cache", buf);

#if defined(MULTITHREADED)
if(myGlobals.numericFlag == 0) {
if(snprintf(buf, sizeof(buf), "%d", myGlobals.droppedAddresses) < 0)
BufferTooShort();
printFeatureConfigInfo(textPrintFlag, "Dropped", buf);
}
#endif
if(snprintf(buf, sizeof(buf), "%d", myGlobals.dnsSniffedCount) < 0)
BufferTooShort();
printFeatureConfigInfo(textPrintFlag, "DNS responses sniffed", buf);

/* **** */

Expand Down Expand Up @@ -2849,7 +2851,7 @@ void printNtopConfigInfo(int textPrintFlag) {

printMutexStatus(textPrintFlag, &myGlobals.gdbmMutex, "gdbmMutex");
printMutexStatus(textPrintFlag, &myGlobals.packetQueueMutex, "packetQueueMutex");
#ifdef ASYNC_ADDRESS_RESOLUTION
#if defined(MULTITHREADED) && defined(ASYNC_ADDRESS_RESOLUTION)
if(myGlobals.numericFlag == 0)
printMutexStatus(textPrintFlag, &myGlobals.addressResolutionMutex, "addressResolutionMutex");
#endif
Expand Down

0 comments on commit b9f29ec

Please sign in to comment.