/////////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////// #include "TROOT.h" #include "TFile.h" #include "TTree.h" #include "TSystem.h" #include "TXMLEngine.h" #include #include "OfflineMon/TOfflineMonitor.hh" #include "Stntuple/oracle/TCdfOracle.hh" ClassImp(TOfflineMonitor) //_____________________________________________________________________________ TOfflineMonitor::TOfflineMonitor() { fHtmlDirectory = ""; fCdfofprd = 0; } //_____________________________________________________________________________ TOfflineMonitor::TOfflineMonitor(const char* Name): TNamed(Name,Name) { const char* offline_mon_dir = gSystem->Getenv("OFFLINE_MON_DIR"); if (offline_mon_dir) { fHtmlDirectory = offline_mon_dir; fHtmlDirectory += "/"; fHtmlDirectory += Name; } else { printf (" %s env var OFFLINE_MON_DIR is not defined\n", Name); } fCdfofprd = new TCdfOracle("cdfofpr2"); } //_____________________________________________________________________________ TOfflineMonitor::~TOfflineMonitor() { delete fCdfofprd; } //_____________________________________________________________________________ int TOfflineMonitor::UpdateNtuple() { return 0; } //_____________________________________________________________________________ int TOfflineMonitor::Init() { return 0; } //_____________________________________________________________________________ int TOfflineMonitor::GetStatus() { return 0; } //_____________________________________________________________________________ int TOfflineMonitor::MakePlots(const char* HtmlFile) { return 0; } //_____________________________________________________________________________ int TOfflineMonitor::MakeHtml(const char* HtmlFile) { return 0; } // Ludovico Cavedon // map form int to status string const char* TOfflineMonitor::statusMap[] = {"OK", "ABNORMAL", "BAD", "DISABLED", "DOWN"}; // MakeXml uses the information stored in monInfo e monSubInfo to generate // an XML file in the HTML output directory and with name monInfo.filename int TOfflineMonitor::MakeXml() { TXMLEngine xe; xmlNodePointer xnode; xmlDocPointer xdoc = xe.NewDoc(); xmlNodePointer xroot = xe.NewChild(NULL, NULL, "system", NULL); xe.DocSetRootElement(xdoc, xroot); if(!monInfo.name.empty()) xe.NewChild(xroot, NULL, "name", monInfo.name.c_str()); xe.NewChild(xroot, NULL, "status", statusMap[monInfo.status]); if(!monInfo.action.empty()) xe.NewChild(xroot, NULL, "action", monInfo.action.c_str()); if(monInfo.masked) xe.NewChild(xroot, NULL, "masked", "yes"); if(!monInfo.url.empty()) { xnode = xe.NewChild(xroot, NULL, "infopage", NULL); xe.NewAttr(xnode, NULL, "url", monInfo.url.c_str()); } if(!monInfo.contactname.empty() || !monInfo.contacturl.empty()) { xnode = xe.NewChild(xroot, NULL, "contact", monInfo.contactname.c_str()); if(!monInfo.contacturl.empty()) xe.NewAttr(xnode, NULL, "url", monInfo.contacturl.c_str()); } if(!monInfo.message.empty()) xe.NewChild(xroot, NULL, "message", monInfo.message.c_str()); std::ostringstream ts; ts << monInfo.timestamp; xe.NewChild(xroot, NULL, "timestamp", ts.str().c_str()); for(MonitorSubInfos::iterator i = monSubInfo.begin(); i != monSubInfo.end(); i++) { xmlNodePointer xmon = xe.NewChild(xroot, NULL, "monitor", NULL); if(!i->name.empty()) xe.NewChild(xmon, NULL, "name", i->name.c_str()); xe.NewChild(xmon, NULL, "status", statusMap[i->status]); if(i->masked) xe.NewChild(xmon, NULL, "masked", "yes"); if(!i->action.empty()) xe.NewChild(xmon, NULL, "action", i->action.c_str()); if(!i->url.empty()) { xnode = xe.NewChild(xmon, NULL, "infopage", NULL); xe.NewAttr(xnode, NULL, "url", i->url.c_str()); } if(!i->contactname.empty() || !i->contacturl.empty()) { xnode = xe.NewChild(xmon, NULL, "contact", i->contactname.c_str()); if( !i->contacturl.empty()) xe.NewAttr(xnode, NULL, "url", i->contacturl.c_str()); } for(MonitorSubInfo::Values::iterator j = i->values.begin(); j != i->values.end(); j++) { xnode = xe.NewChild(xmon, NULL, "value", j->val.c_str()); xe.NewAttr(xnode, NULL, "grouping", j->grouping.c_str()); xe.NewAttr(xnode, NULL, "group", j->group.c_str()); } } // write xml file xe.SaveDoc(xdoc, fHtmlDirectory + "/" + monInfo.filename, 1); return 0; }