3 #include <boost/algorithm/string.hpp>
12 namespace dqmservices {
14 namespace fs = boost::filesystem;
16 #define MAX_LOG_SIZE 64*1024
22 if (gethostname(host ,
sizeof(host)) == -1) {
24 <<
"Internal error, cannot get host name";
42 extra_.put_child(name, data);
58 using std::chrono::duration_cast;
59 using std::chrono::milliseconds;
82 path_id =
id +
".jsn";
97 pt.put(
"sequence",
fseq_);
98 pt.put(
"type",
"dqm-source-state");
100 pt.put(
"lumi", lumi);
103 pt.put(
"events_rate", rate);
107 pt.put(
"stderr", log);
112 pt.add_child(
"extra",
extra_);
115 std::ofstream
file(tmp_path);
116 write_json(file, pt,
true);
122 rename(tmp_path.c_str(), final_path.c_str());
126 int fd = open(
"/proc/self/cmdline", O_RDONLY);
130 unsigned char buf[1024];
131 int nbytesread =
read(fd, buf, 1024);
136 buf[nbytesread-1] = 0;
138 unsigned char *
end = buf + nbytesread;
139 for (
unsigned char *
p = buf;
p <
end; ) {
142 child.put(
"", token);
143 cmdline.push_back(std::make_pair(
"", child));
145 if ((
tag_.size() == 0) &&
146 (token.find(
".py") != std::string::npos)) {
151 boost::replace_last(
tag_,
".py",
"");
152 boost::replace_last(
tag_,
"_cfg",
"");
160 ps_info_.put_child(
"cmdline", cmdline);
166 std::ifstream
in(
"/proc/self/status");
170 while (std::getline(in, line)) {
171 size_t pos = line.find(
':');
172 if (pos == std::string::npos)
179 data.put(line, value);
195 return "error: can't read the stderr link.";
198 if (strstr(buf,
"/dev/") !=
NULL) {
200 return "error: stderr is a special file.";
204 FILE *sr = fopen(buf ,
"rb");
206 return "error: can't open the stderr (deleted?).";
210 fseek(sr, 0, SEEK_END);
211 long size = ftell(sr);
217 fseek(sr, from, SEEK_SET);
226 start = strchr(start,
'\n');
240 return "error: stderr is not a seek-able file.";
T getUntrackedParameter(std::string const &, T const &) const
tuple start
Check for commandline option errors.
void registerExtra(std::string name, ptree data)
string format
Some error handling for the usage.
boost::filesystem::path json_path_
void reportLumiSection(int run, int lumi)
void reportEvents(int nevts)
long last_report_nevents_
std::string hackoutTheStdErr()
#define DEFINE_FWK_SERVICE(type)
std::chrono::high_resolution_clock::time_point last_report_time_
void fillProcessInfoCmdline()
void reportLumiSectionUnsafe(int run, int lumi)
char data[epos_bytes_allocation]
DQMMonitoringService(const edm::ParameterSet &, edm::ActivityRegistry &)
void fillProcessInfoStatus()
tuple size
Write out results.