From 1f8fa16d1c99dc84b9bb40210edd172171ddcb56 Mon Sep 17 00:00:00 2001 From: hadaq Date: Thu, 15 Jul 2010 17:51:49 +0000 Subject: [PATCH] port nr added to stat dump. Sergey. --- hadaq/netmem.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/hadaq/netmem.c b/hadaq/netmem.c index 11de1c1..c255962 100644 --- a/hadaq/netmem.c +++ b/hadaq/netmem.c @@ -1,4 +1,4 @@ -static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.40 2010-07-07 08:43:27 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.41 2010-07-15 17:51:49 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L #define SYSLOG_NAMES @@ -40,6 +40,9 @@ typedef struct TheArgsS { unsigned int buffStat; char shmname[PARAM_MAX_VALUE_LEN]; char evtstat[PARAM_MAX_VALUE_LEN]; + + unsigned long portNr[MAXINPATH]; + int portNrCnt; } TheArgs; typedef struct TheStatsS { @@ -135,14 +138,14 @@ static void argsDefault(TheArgs *my) } my->queueVarSizeCnt = 0; /* no varible queue sizes by default */ + my->portNrCnt = 0; + my->buffStat = 0; strcpy(my->shmname, ""); sprintf(my->evtstat, "%s_evtstat.txt", getenv("DAQ_SETUP")); } - - static int argsFromCL(TheArgs *my, int argc, char *argv[]) { extern char *optarg; @@ -193,6 +196,23 @@ static int argsFromCL(TheArgs *my, int argc, char *argv[]) my->inPathCnt = inPathCntFromParam; } + /* Extract port numbers */ + char fam[32]; + char pa[32]; + char ep[32]; + int port; + + for (i = 0; i < my->inPathCnt; i++) { + if (0 == (sscanf(my->inPath[i], "%[^:]:%[^:]:%s", fam, pa, ep))) { + syslog(LOG_ERR, "%s, %d: %s", __FILE__, __LINE__, "sscanf failed."); + sleep(5); + } else { + port = atoi(ep); + my->portNr[i] = port; + my->portNrCnt++; + } + } + return 0; } @@ -427,8 +447,10 @@ static void statsDump(TheArgs *theArgs, NetTrans **my, int interval) if (theArgs->isStandalone && strcmp(theArgs->verbosity, "info") == 0 && (dT = (time(NULL) - lastTime)) >= interval && !(theArgs->buffStat)) { + fputs("==============================================================================\n", stderr); for (i = 0; i < theArgs->nrOfMsgs; i++) { + printf("port:%6d ------------------------------------------------------------------\n", theArgs->portNr[i]); fprintf(stderr, "%17s%02d:%6s", "pktsReceived", i, unit(*my[i]->pktsReceived)); fprintf(stderr, "%17s%02d:%6s", "pktsDiscarded", i, unit(*my[i]->pktsDiscarded)); fprintf(stderr, "%15s%02d :%6s", "bytesReceived", i, unit(*my[i]->bytesReceived)); @@ -438,7 +460,6 @@ static void statsDump(TheArgs *theArgs, NetTrans **my, int interval) fprintf(stderr, "%15s%02d/s:%6s", "bytesReceived", i, unit(*my[i]->bytesReceived - lastBR[i])); lastBR[i] = *my[i]->bytesReceived; fputc('\n', stderr); - fputs("------------------------------------------------------------------------------\n", stderr); if ((long) (*my[i]->pktsReceived) - (long) lastPR < 0) { lastPR[i] = 0; @@ -453,6 +474,7 @@ static void statsDump(TheArgs *theArgs, NetTrans **my, int interval) lastPD[i] = *my[i]->pktsDiscarded; lastMD[i] = *my[i]->msgsDiscarded; } + fputs("==============================================================================\n", stderr); lastTime += dT; } -- 2.43.0