File indexing completed on 2025-08-03 08:20:54
0001 #ifndef MACROS_COMMONFUNCS_C
0002 #define MACROS_COMMONFUNCS_C
0003
0004 #include <onlmon/OnlMonClient.h>
0005
0006
0007 R__LOAD_LIBRARY(libonlmonclient.so)
0008
0009 void CreateHostList(const int online = 0)
0010 {
0011 OnlMonClient *cl = OnlMonClient::instance();
0012 if (!online)
0013 {
0014 cl->AddServerHost("localhost");
0015 for (int i = 2061; i <= 2068; i++)
0016 {
0017 string node = "rcas" + to_string(i);
0018 cl->AddServerHost(node);
0019 }
0020 for (int i = 1; i <= 8; i++)
0021 {
0022 string node = "sphnx0" + to_string(i);
0023 cl->AddServerHost(node);
0024 }
0025 cl->AddServerHost("sphnxdev01");
0026 }
0027 else if (online == 1)
0028 {
0029 const char *hostlist = gSystem->Getenv("ONLMON_RUNDIR");
0030 char hostlistname[200];
0031 if (hostlist)
0032 {
0033 char node[20];
0034 sprintf(hostlistname, "%s/monitoring_hosts.list", hostlist);
0035 FILE *f = fopen(hostlistname, "r");
0036 while (fscanf(f, "%19s", &node[0]) != EOF)
0037 {
0038 cout << "adding " << node << endl;
0039 cl->AddServerHost(node);
0040 }
0041 }
0042 }
0043 else
0044 {
0045 cl->AddServerHost("localhost");
0046 }
0047 }
0048
0049 void CleanUpClient()
0050 {
0051 OnlMonClient *cl = OnlMonClient::instance();
0052 delete cl;
0053 gSystem->Exit(0);
0054 return;
0055 }
0056
0057 void ClearCanvases()
0058 {
0059 TSeqCollection* allCanvases = gROOT->GetListOfCanvases();
0060 TCanvas* canvas = nullptr;
0061 while ((canvas = (TCanvas*) allCanvases->First()))
0062 {
0063 std::cout << "Deleting Canvas " << canvas->GetName() << std::endl;
0064 delete canvas;
0065 }
0066 }
0067
0068 void CreateSubsysHostlist(const std::string &list, const int online)
0069 {
0070 if (online != 1)
0071 {
0072 CreateHostList(online);
0073 return;
0074 }
0075 OnlMonClient *cl = OnlMonClient::instance();
0076 const char *hostlistdir = gSystem->Getenv("ONLMON_RUNDIR");
0077 char hostlistname[200];
0078 if (hostlistdir)
0079 {
0080 char node[20];
0081 sprintf(hostlistname, "%s/%s", hostlistdir,list.c_str());
0082 cout << "trying to open " << hostlistname << endl;
0083 FILE *f = fopen(hostlistname, "r");
0084 if (! f)
0085 {
0086 CreateHostList(online);
0087 return;
0088 }
0089 while (fscanf(f, "%19s", &node[0]) != EOF)
0090 {
0091 cout << "adding " << node << endl;
0092 cl->AddServerHost(node);
0093 }
0094 fclose(f);
0095 }
0096 }
0097
0098 #endif