Belle II Software  release-08-01-10
nodedump.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 //#define DESY
10 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include <string.h>
15 
16 #include "daq/rfarm/manager/RFConf.h"
17 #include "daq/rfarm/manager/RFSharedMem.h"
18 #include "daq/rfarm/manager/RFFlowStat.h"
19 
20 using namespace std;
21 using namespace Belle2;
22 
23 int main(int argc, char** argv)
24 {
25 
26  if (argc < 2) {
27  printf("Usage : nodedump unitname nodename\n");
28  return -1;
29  }
30 
31  char host[256];
32  gethostname(host, sizeof(host));
33 
34  char* confdir = getenv("RFARM_CONFDIR");
35  string confpath = string(confdir) + "/" + string(argv[1]) + ".conf";
36 
37  RFConf conf(confpath.c_str());
38 
39  // char* conffile = getenv("RFARM_CONFFILE");
40  // RFConf conf(conffile);
41 
42  char nodename[512];
43  int nid = 0;
44  int idlist[256];
45  char item[256][7];
46 
47  if (argc >= 3) {
48  if (strstr(argv[2], "dist") != NULL) { // distributor
49  strcpy(nodename, "distributor");
50  int nnodes = conf.getconfi("processor", "nnodes");
51  idlist[0] = RF_INPUT_ID;
52  strcpy(item[0], "IN ");
53  for (int i = 0; i < nnodes; i++) {
54  idlist[i + 1] = i;
55  sprintf(item[i + 1], "OUT%2.2d ", i);
56  }
57  nid = nnodes + 1;
58  } else if (strstr(argv[2], "col") != NULL) { // collector
59  strcpy(nodename, "collector");
60  int nnodes = conf.getconfi("processor", "nnodes");
61  for (int i = 0; i < nnodes; i++) {
62  idlist[i] = i;
63  sprintf(item[i], "IN%2.2d ", i);
64  }
65  idlist[nnodes] = RF_OUTPUT_ID;
66  strcpy(item[nnodes], "OUT ");
67  nid = nnodes + 1;
68  } else if (strstr(argv[2], "roi") != NULL) { // collector
69  strcpy(nodename, "roisender");
70  idlist[0] = RF_ROI_ID;
71  strcpy(item[0], "OUT ");
72  nid = 1;
73  }
74  } else {
75 #ifdef DESY
76  // Special treatment for DESY test nodes!!
77  strcpy(nodename, "evp_");
78  char hostnamebuf[256];
79  gethostname(hostnamebuf, sizeof(hostnamebuf));
80  strcat(&nodename[4], &hostnamebuf[6]);
81  int lend = strlen(nodename);
82  nodename[lend + 1] = (char)0;
83  nodename[lend] = nodename[lend - 1];
84  strncpy(&nodename[lend - 1], "0", 1);
85  // End of DESY special treatment
86 #else
87  sprintf(nodename, "evp_%s", host);
88 #endif
89  idlist[0] = 0;
90  strcpy(item[0], "IN ");
91  idlist[1] = 1;
92  strcpy(item[1], "OUT ");
93  nid = 2;
94  }
95  string shmname = string(conf.getconf("system", "unitname")) + ":" +
96  string(nodename);
97  RFFlowStat flow((char*)shmname.c_str());
98 
99  printf("nodename = %s, nid = %d\n", nodename, nid);
100  printf("id range : %d to %d\n", idlist[0], idlist[nid - 1]);
101  // printf ( "cell nevt nque flowrate avesize evtrate elapsed\n" );
102  // 123456789012345678901234567890123456789012345678901234567890
103  printf(" At : Nevent Nqueue Flow(MB/s) Size(KB) Rate(Hz)\n");
104  for (int i = 0; i < nid; i++) {
105  RfShm_Cell& cell = flow.getinfo(idlist[i]);
106  // printf ( "cell %2.2d : %8d %4d %7.2f %7.2f %7.2f\n",
107  // idlist[i],
108  // cell.nevent, cell.nqueue, cell.flowrate, cell.avesize,
109  // cell.evtrate );
110  printf("%s : %10d %10d %10.2f %10.2f %10.2f\n",
111  item[i],
112  cell.nevent, cell.nqueue, cell.flowrate, cell.avesize,
113  cell.evtrate);
114  }
115 }
116 
117 
118 
119 
120 
121 
122 
123 
Abstract base class for different kinds of events.
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91