-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.30 2008-03-31 17:48:20 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/netmem.c,v 6.31 2008-04-08 14:56:47 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
long varQSize[MAXINPATH];
int varQSizeCnt;
char verbosity[PARAM_MAX_VALUE_LEN];
+ unsigned int buffStat;
} TheArgs;
static jmp_buf terminateJmp;
static void usage(const char *progName)
{
syslog(LOG_ERR, "Usage: %s -i inPath [-i inPath] -m nrOfMsgs [-p priority]", progName);
+ syslog (LOG_ERR, "[-b 0|1] show fill levels of buffers]");
}
static void argsDump(TheArgs *my)
for (i = 0; i < MAXINPATH; i++) {
my->varQSize[i] = 1 * 1024 * 1024;
}
+ my->buffStat = 0;
}
static int argsFromCL(TheArgs *my, int argc, char *argv[])
inPathCntFromParam = my->inPathCnt;
my->inPathCnt = 0;
- while ((i = getopt(argc, argv, "ai:m:q:p:v:")) != -1) {
+ while ((i = getopt(argc, argv, "ai:m:q:p:v:b:")) != -1) {
switch (i) {
case 'm':
my->nrOfMsgs = atoi(optarg);
case 'v':
strcpy(my->verbosity, optarg);
break;
+ case 'b':
+ my->buffStat = strtoul (optarg, NULL, 0);
+ break;
default:
return -1;
break;
return retVal;
}
+static void printTime()
+{
+ struct timeval tv;
+ struct tm* ptm;
+ char time_string[40];
+ long milliseconds;
+
+ gettimeofday( &tv, NULL );
+
+ /* Obtain the time of day, and convert it to a tm struct. */
+ ptm = localtime (&tv.tv_sec);
+
+ /* Format the date and time, down to a single second. */
+ strftime (time_string, sizeof (time_string), "%Y-%m-%d %H:%M:%S", ptm);
+
+ /* Compute milliseconds from microseconds. */
+ milliseconds = tv.tv_usec / 1000;
+
+ /* Print the formatted time, in seconds, followed by a decimal point
+ and the milliseconds. */
+ printf ("Time: %s.%03ld\n", time_string, milliseconds);
+}
+
+static void
+statsBufferDump (TheArgs * theArgs, float interval, ShmTrans **shmtr, NetTrans **my)
+{
+ static time_t t0 = 0;
+ time_t t, dT;
+ int i, j;
+ int col = 0;
+ char emptybuffer[] = "-";
+ int outputGraph = 1; /* Graphical output */
+ int outputNum = 0; /* Numerical output */
+
+ t = time (NULL);
+ dT = t - t0;
+
+ /* fprintf (stderr, " dT: %.0lf interval: %.0lf", (double)dT, interval); */
+
+ if (dT >= interval && theArgs->buffStat == 1)
+ {
+
+ if( outputNum == 1) {
+ fputs("==============================================================================\n\n",stderr);
+ for(i=0; i<theArgs->nrOfMsgs; i++) {
+
+ fprintf (stderr, "q[%2d]: ", i);
+ if (shmtr[i] != NULL)
+ if (theArgs->varQSize[i]*2 - HadTuQueue_size(shmtr[i]->wrQueue) > 0) {
+ fprintf (stderr, "%8d ", HadTuQueue_size(shmtr[i]->wrQueue));
+ }
+ else {
+ fprintf (stderr, "%8s ", "EXCEEDED");
+ }
+ else
+ fprintf (stderr, "%8s ", emptybuffer);
+
+ col++;
+ if (col == 6) {
+ fputc ('\n', stderr);
+ col = 0;
+ }
+ }
+ }
+
+ if( outputGraph == 1 ){
+ fputs ("------------------ buffer fill levels ----------------------------------------\n", stderr);
+
+ float buffSize, queueSize, pktsDisc;
+ int maxnorm = 10.;
+
+ for( j=0; j<maxnorm; j++ ){
+ fprintf (stderr, "%1d ", maxnorm - j - 1);
+ for( i=0; i<theArgs->nrOfMsgs; i++ ){
+ buffSize = 2*theArgs->varQSize[i];
+ queueSize = HadTuQueue_size(shmtr[i]->wrQueue);
+
+ if(maxnorm - maxnorm*queueSize/buffSize < j){
+ fputc( '|', stderr );
+ }
+ else{
+ fputc( ' ', stderr );
+ }
+ }
+ fputc( '\n', stderr );
+ }
+
+ /* The following is just to print the numbers of buffers*/
+ int factor, mod;
+
+ fputs( "q:", stderr );
+ factor = 0;
+ for( i=0; i<theArgs->nrOfMsgs; i++ ) {
+ mod = i%10;
+ fprintf (stderr, "%1d", mod);
+ }
+ fputc( '\n', stderr );
+
+ fputs( " ", stderr );
+ for( i=0; i<theArgs->nrOfMsgs; i++ ) {
+ mod = i%10;
+ if( mod == 0 )
+ fprintf (stderr, "%1d", i/10 );
+ else
+ fputc( ' ', stderr );
+ }
+ fputc( '\n', stderr );
+
+ fputs( "------------------ discarded packets -----------------------------------------\n", stderr );
+ for( j=0; j<maxnorm; j++ ){
+ fprintf (stderr, "%1d ", maxnorm - j - 1);
+ for( i=0; i<theArgs->nrOfMsgs; i++ ){
+ pktsDisc = (*my[i]->pktsDiscarded);
+
+ if(maxnorm - (pktsDisc + maxnorm - 1)/maxnorm < j){
+ fputc( 'D', stderr );
+ }
+ else{
+ fputc( ' ', stderr );
+ }
+ }
+ fputc( '\n', stderr );
+ }
+
+ /* get wall-clock time */
+ printTime();
+ }
+ }
+
+ t0 = t;
+}
+
static void statsDump(TheArgs *theArgs, NetTrans **my, int interval)
{
static unsigned long lastBR[MAXINPATH];
int i;
- if (theArgs->isStandalone && strcmp(theArgs->verbosity, "info") == 0 && (dT = (time(NULL) - lastTime)) >= interval) {
+ if (theArgs->isStandalone && strcmp(theArgs->verbosity, "info") == 0 && (dT = (time(NULL) - lastTime)) >= interval && theArgs->buffStat == 0) {
fputs("==============================================================================\n", stderr);
for (i = 0; i < theArgs->nrOfMsgs; i++) {
fprintf(stderr, "%17s%02d:%6s", "pktsReceived", i, unit(*my[i]->pktsReceived));
long msgsCompleted;
statsDump(theArgs, netTrans, 1);
+ statsBufferDump (theArgs, 1, shmTrans, netTrans);
for (i = 0; i < theArgs->nrOfMsgs; i++) {
if (hadTu[i] == NULL) {