3 #include "xdaq/NamespaceURI.h"
5 #include "xoap/SOAPEnvelope.h"
6 #include "xoap/SOAPBody.h"
7 #include "xoap/domutils.h"
9 #include <boost/tokenizer.hpp>
11 #include <netinet/in.h>
17 #include "cgicc/CgiDefs.h"
18 #include "cgicc/Cgicc.h"
19 #include "cgicc/FormEntry.h"
20 #include "cgicc/FormFile.h"
21 #include "cgicc/HTMLClasses.h"
34 : xdaq::Application(s)
35 , log_(getApplicationLogger())
40 , cpustat_(std::vector<std::vector<int> >(0))
45 getApplicationDescriptor()->getContextDescriptor()->getURL()+
"/"+
46 getApplicationDescriptor()->getURN();
47 class_ =getApplicationDescriptor()->getClassName();
48 instance_=getApplicationDescriptor()->getInstance();
49 hostname_=getApplicationDescriptor()->getContextDescriptor()->getURL();
70 xdata::InfoSpace *ispace = getApplicationInfoSpace();
72 ispace->fireItemAvailable(
"runNumber", &
runNumber_ );
73 getApplicationInfoSpace()->addItemChangedListener(
"runNumber",
this);
86 if (e.type()==
"ItemChangedEvent" ) {
87 std::string item =
dynamic_cast<xdata::ItemChangedEvent&
>(
e).itemName();
89 if ( item ==
"runNumber") {
90 LOG4CPLUS_WARN(getApplicationLogger(),
91 "New Run was started - iDie will reset");
103 xoap::SOAPPart
part =
msg->getSOAPPart();
104 xoap::SOAPEnvelope env =part.getEnvelope();
105 xoap::SOAPBody body =env.getBody();
106 DOMNode *
node =body.getDOMNode();
107 DOMNodeList *bodyList=node->getChildNodes();
109 std::string commandName;
111 for (
unsigned int i=0;
i<bodyList->getLength();
i++) {
112 command = bodyList->item(
i);
113 if(command->getNodeType() == DOMNode::ELEMENT_NODE) {
114 commandName = xoap::XMLCh2String(command->getLocalName());
119 if (commandName.empty()) {
127 xoap::MessageReference reply = xoap::createMessage();
128 xoap::SOAPEnvelope envelope = reply->getSOAPPart().getEnvelope();
129 xoap::SOAPName responseName = envelope.createName(commandName+
"Response",
131 xoap::SOAPBodyElement responseElem =
132 envelope.getBody().addBodyElement(responseName);
136 if(commandName ==
"Configure") state =
"Ready";
137 else if(commandName ==
"Enable") state =
"Enabled";
138 else if(commandName ==
"Stop") state =
"Ready";
139 else if(commandName ==
"Halt") state =
"Halted";
142 xoap::SOAPName stateName = envelope.createName(
"state",
144 xoap::SOAPElement stateElem = responseElem.addChildElement(stateName);
145 xoap::SOAPName attributeName = envelope.createName(
"stateName",
147 stateElem.addAttribute(attributeName,state);
163 cgicc::Cgicc cgi(
in);
164 std::string method = cgi.getEnvironment().getRequestMethod();
165 if(method ==
"POST"){
167 std::vector<cgicc::FormEntry> el1 = cgi.getElements();
168 cgi.getElement(
"run",el1);
170 run = el1[0].getIntegerValue();
179 std::string hostname = cgi.getEnvironment().getRemoteHost();
180 std::transform(hostname.begin(), hostname.end(),
181 hostname.begin(), ::toupper);
182 fus_[hostname] = fuinstance;
185 *
out <<
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"
186 <<
"<html><head><title>" << getApplicationDescriptor()->getClassName()
187 << getApplicationDescriptor()->getInstance() <<
"</title>"
188 <<
"<meta http-equiv=\"REFRESH\" content=\"0;url=/evf/html/idiePage.html\">"
203 *
out <<
"<tr><td>"<<fus_.size()<<
"</td><td>" << totalCores_
204 <<
"</td><td></td></tr>" << std::endl;
213 time_t
now = tv.tv_sec;
214 for(
ifmap i = fus_.begin();
i != fus_.end();
i++)
215 if((*i).second.ccount != 0){
217 << (now-(*i).second.tstamp<300 ?
"style=\"background-color:red\"" :
"")
218 <<
">"<<(*i).first<<
"</td><td>"
219 << (*i).second.ccount <<
"</td>"
220 <<
"<td onClick=loaddump(\'" << url_.value_ <<
"/dump?name="
221 << (*i).first <<
"\')>" << (*i).second.cpids.back()
222 <<
"</td><td>" <<(*i).second.signals.back()
223 <<
"</td></tr>" << std::endl;
231 cgicc::Cgicc cgi(
in);
233 std::vector<cgicc::FormEntry> el1;
234 cgi.getElement(
"name",el1);
236 std::string hostname = el1[0].getValue();
237 std::transform(hostname.begin(), hostname.end(),
238 hostname.begin(), ::toupper);
239 ifmap fi = fus_.find(hostname);
241 *
out << (*fi).second.stacktraces.back() << std::endl;
244 for(fi=fus_.begin(); fi != fus_.end(); fi++)
245 std::cout <<
"known hosts: " << (*fi).first << std::endl;
260 cgicc::Cgicc cgi(
in);
266 std::cout <<
"iChoke, last_ls= " << last_ls_ << std::endl;
267 if(last_ls_==0)
return;
268 *
out <<
"Last ls=" << last_ls_ <<
"Cpu statistics="
269 << cpuentries_[last_ls_-1] << std::endl;
270 *
out <<
"================" << std::endl;
274 if(tmp[i]!=0) *
out << mapmod_[tmp.
ii(i)] <<
" " << float(tmp[i])/float(cpuentries_[last_ls_-1]) << std::endl;
278 unsigned int begin = last_ls_<10 ? 0 : last_ls_-10;
279 for(i=begin; i < last_ls_; i++)
280 *
out << std::setw(9) << i +1 <<
" ";
282 for(i=begin; i < last_ls_; i++)
283 *
out <<
"----------";
285 for(i=begin; i < last_ls_; i++)
286 *
out << std::setw(8) << float(cpustat_[i][2])/float(cpuentries_[i]) <<
" ";
289 begin = last_ls_<10 ? 0 : last_ls_-10;
290 for(i=begin; i < last_ls_; i++)
291 *
out << std::setw(9) << i +1 <<
" ";
293 for(i=begin; i < last_ls_; i++)
294 *
out <<
"----------";
296 for(i=begin; i < last_ls_; i++)
297 *
out << std::setw(8) << float(trp_[i].eventSummary.totalEventsPassed)/float(trp_[i].eventSummary.totalEvents) <<
" ";
299 for(i=begin; i < last_ls_; i++)
300 *
out << std::setw(8) << trp_[
i].eventSummary.totalEvents <<
" ";
303 for(
int j = 0;
j < trp_[last_ls_-1].trigPathsInMenu;
j++)
305 for(i=begin; i < last_ls_; i++)
306 *
out << std::setw(8) << trp_[
i].trigPathSummaries[
j].timesPassed <<
"("
307 << trp_[
i].trigPathSummaries[
j].timesPassedL1 <<
")("
308 << trp_[
i].trigPathSummaries[
j].timesPassedPs <<
") ";
312 for(
int j = 0;
j < trp_[last_ls_-1].endPathsInMenu;
j++)
314 for(i=begin; i < last_ls_; i++)
315 *
out << std::setw(8) << trp_[
i].endPathSummaries[
j].timesPassed <<
" ";
316 *
out << mappath_[
j+trp_[last_ls_-1].trigPathsInMenu];
330 time_t
now = tv.tv_sec;
331 cgicc::Cgicc cgi(
in);
332 unsigned int run = 0;
337 std::vector<cgicc::FormEntry> el1;
338 el1 = cgi.getElements();
339 for(
unsigned int i = 0;
i < el1.size();
i++)
342 cgi.getElement(
"run",el1);
345 run = el1[0].getIntegerValue();
348 cgi.getElement(
"stacktrace",el1);
354 if(el1[0].
getValue().find(
"Dead")==0){
356 std::string
host = cgi.getEnvironment().getRemoteHost();
357 std::transform(host.begin(), host.end(),
358 host.begin(), ::toupper);
359 ifmap fi = fus_.find(host);
366 std::string st = el1[0].getValue();
368 size_t psig = st.find(
"signal");
369 if(psig != std::string::npos)
370 sig = st.substr(psig,9);
371 std::string
host = cgi.getEnvironment().getRemoteHost();
372 std::transform(host.begin(), host.end(),
373 host.begin(), ::toupper);
374 ifmap fi = fus_.find(host);
376 (*fi).second.tstamp =
now;
377 (*fi).second.ccount++;
378 (*fi).second.cpids.push_back(cpid);
379 (*fi).second.signals.push_back(sig);
380 (*fi).second.stacktraces.push_back(st);
385 cgi.getElement(
"legenda",el1);
388 parsePathLegenda(el1[0].
getValue());
390 cgi.getElement(
"trp",el1);
393 unsigned int lsid =
run;
394 parsePathHisto((
unsigned char*)(el1[0].
getValue().c_str()),lsid);
405 std::cout <<
"postEntryiChoke " << std::endl;
406 unsigned int lsid = 0;
407 cgicc::Cgicc cgi(
in);
411 std::vector<cgicc::FormEntry> el1;
412 el1 = cgi.getElements();
413 for(
unsigned int i = 0;
i < el1.size();
i++)
416 cgi.getElement(
"run",el1);
419 lsid = el1[0].getIntegerValue();
422 cgi.getElement(
"legenda",el1);
425 parseModuleLegenda(el1[0].
getValue());
427 cgi.getElement(
"trp",el1);
430 parseModuleHisto(el1[0].getStrippedValue().c_str(),lsid);
446 boost::char_separator<char> sep(
",");
447 boost::tokenizer<boost::char_separator<char> >
tokens(leg, sep);
448 for (
boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = tokens.begin();
449 tok_iter != tokens.end(); ++tok_iter){
450 mapmod_.push_back((*tok_iter));
461 std::cout <<
"parseModuleHisto ls=" << lsid << std::endl;
463 int *trp = (
int*)crp;
478 std::cout <<
"parsePathLegenda" << std::endl;
481 boost::char_separator<char> sep(
",");
482 boost::tokenizer<boost::char_separator<char> >
tokens(leg, sep);
483 for (
boost::tokenizer<boost::char_separator<char> >::iterator tok_iter = tokens.begin();
484 tok_iter != tokens.end(); ++tok_iter){
491 std::cout <<
"parsePathHisto ls=" << lsid << std::endl;
493 if(lsid>=
trp_.size()){
506 XDAQ_INSTANTIATOR_IMPL(
iDie)
static const char runNumber_[]
xdata::UnsignedInteger32 runNumber_
xdata::UnsignedInteger32 instance_
iDie(xdaq::ApplicationStub *s)
xdata::String configString_
void parsePathLegenda(std::string)
boost::tokenizer< boost::char_separator< char > > tokenizer
void postEntryiChoke(xgi::Input *in, xgi::Output *out)
void addToReport(TriggerReportStatic *trs, TriggerReportStatic *trp, unsigned int lumisection)
void iChoke(xgi::Input *in, xgi::Output *out)
void parseModuleLegenda(std::string)
void updater(xgi::Input *in, xgi::Output *out)
std::vector< int > cpuentries_
std::vector< int > trpentries_
std::vector< TriggerReportStatic > trp_
std::vector< std::vector< int > > cpustat_
void reset(TriggerReportStatic *)
xoap::MessageReference fsmCallback(xoap::MessageReference msg)
std::string getName(Reflex::Type &cc)
void actionPerformed(xdata::Event &e)
void detailsTable(xgi::Input *in, xgi::Output *out)
void postEntry(xgi::Input *in, xgi::Output *out)
void parsePathHisto(const unsigned char *, unsigned int)
void dumpTable(xgi::Input *in, xgi::Output *out)
void defaultWeb(xgi::Input *in, xgi::Output *out)
void iChokeMiniInterface(xgi::Input *in, xgi::Output *out)
std::vector< std::string > mappath_
std::vector< std::vector< double > > tmp
void parseModuleHisto(const char *, unsigned int)
void summaryTable(xgi::Input *in, xgi::Output *out)
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
void reset(double vett[256])
std::vector< std::string > mapmod_