Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-07 08:16:10

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