Belle II Software development
rf_monitor.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#include <cstdlib>
10#include <cstring>
11#include <stdio.h>
12
13#include "nsm2/belle2nsm.h"
14
15#include "daq/rfarm/manager/RFConf.h"
16#include "daq/rfarm/manager/RfNodeInfo.h"
17
18#define MONITOR_NODE "rf_mon"
19
20using namespace std;
21using namespace Belle2;
22
23int main()
24{
25 // 0. Conf file
26 char* conffile = getenv("RFARM_CONFFILE");
27 RFConf conf(conffile);
28
29 char* format = conf.getconf("system", "nsmdata");
30
31 // 1. Initialize NSM
32 if (!b2nsm_init(MONITOR_NODE)) {
33 printf("Error in initializing NSM : %s\n", b2nsm_strerror());
34 exit(-1);
35 }
36
37 printf("----- Control Nodes\n");
38
39 // 1. Dump distributor node
40 char* node = conf.getconf("distributor", "nodename");
41 RfNodeInfo* nshm = (struct RfNodeInfo*) b2nsm_openmem(node, format, 1);
42 printf(" RFIN : %8d %4d %5.2f %5.2f ; %6.2f; %5.2f\n",
43 nshm->nevent_in, nshm->nqueue_in, nshm->avesize_in,
44 nshm->flowrate_in, nshm->evtrate_in, nshm->loadave);
45 // 2. Dump collector node
46 node = conf.getconf("collector", "nodename");
47 nshm = (struct RfNodeInfo*) b2nsm_openmem(node, format, 1);
48 printf(" RFOUT : %8d %4d %5.2f %5.2f ; %6.2f; %5.2f\n",
49 nshm->nevent_out, nshm->nqueue_out, nshm->avesize_out,
50 nshm->flowrate_out, nshm->evtrate_out, nshm->loadave);
51
52 printf("----- Processing Nodes\n");
53
54 // 3. Dump processing nodes
55 int maxnodes = conf.getconfi("processor", "nnodes");
56 int idbase = conf.getconfi("processor", "idbase");
57 char* hostbase = conf.getconf("processor", "nodebase");
58 char* badlist = conf.getconf("processor", "badlist");
59
60 char hostnode[512], idname[3];
61 int nnodes = 0;
62 for (int i = 0; i < maxnodes; i++) {
63 sprintf(idname, "%2.2d", idbase + i);
64 if (badlist == NULL ||
65 strstr(badlist, idname) == 0) {
66 sprintf(hostnode, "evp_%s%2.2d", hostbase, idbase + i);
67 nshm = (struct RfNodeInfo*) b2nsm_openmem(hostnode, format, 1);
68 printf(" %s(in) : %8d %4d %5.2f %5.2f ; %6.2f; %5.2f\n",
69 hostnode,
70 nshm->nevent_in, nshm->nqueue_in, nshm->avesize_in,
71 nshm->flowrate_in, nshm->evtrate_in, nshm->loadave);
72 printf(" %s(out): %8d %4d %5.2f %5.2f ; %6.2f; %5.2f\n",
73 hostnode,
74 nshm->nevent_out, nshm->nqueue_out, nshm->avesize_out,
75 nshm->flowrate_out, nshm->evtrate_out, nshm->loadave);
76 nnodes++;
77 }
78 }
79 /*
80 // Test
81
82 printf ( "----- Test\n" );
83 strcpy ( hostnode, "evp_hltwk02" );
84 nshm = (struct RfNodeInfo*) b2nsm_openmem(hostnode, format, 1);
85 printf ( " %s(in) : %8d %4d %5.2f %5.2f ; %6.2f; %5.2f\n",
86 hostnode,
87 nshm->nevent_in, nshm->nqueue_in, nshm->avesize_in,
88 nshm->flowrate_in, nshm->evtrate_in, nshm->loadave );
89 printf ( " %s(out): %8d %4d %5.2f %5.2f ; %6.2f; %5.2f\n",
90 hostnode,
91 nshm->nevent_out, nshm->nqueue_out, nshm->avesize_out,
92 nshm->flowrate_out, nshm->evtrate_out, nshm->loadave );
93 */
94
95}
Abstract base class for different kinds of events.
STL namespace.