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";
45 extra_.put_child(name, data);
61 using std::chrono::duration_cast;
62 using std::chrono::milliseconds;
86 path_id =
id +
".jsn";
100 pt.put(
"sequence",
fseq_);
101 pt.put(
"type",
"dqm-source-state");
103 pt.put(
"lumi", lumi);
106 pt.put(
"events_rate", rate);
112 pt.put(
"stderr", log);
117 pt.add_child(
"extra",
extra_);
120 std::ofstream
file(tmp_path);
121 write_json(file, pt,
true);
127 rename(tmp_path.c_str(), final_path.c_str());
131 int fd = open(
"/proc/self/cmdline", O_RDONLY);
135 unsigned char buf[1024];
136 int nbytesread =
read(fd, buf, 1024);
141 buf[nbytesread-1] = 0;
143 unsigned char *
end = buf + nbytesread;
144 for (
unsigned char *
p = buf;
p <
end; ) {
147 child.put(
"", token);
148 cmdline.push_back(std::make_pair(
"", child));
150 if ((
tag_.size() == 0) &&
151 (token.find(
".py") != std::string::npos)) {
156 boost::replace_last(
tag_,
".py",
"");
157 boost::replace_last(
tag_,
"_cfg",
"");
159 size_t pos =
tag_.rfind(
"/");
160 if (pos != std::string::npos) {
170 ps_info_.put_child(
"cmdline", cmdline);
176 std::ifstream
in(
"/proc/self/status");
180 while (std::getline(in, line)) {
181 size_t pos = line.find(
':');
182 if (pos == std::string::npos)
189 data.put(line, value);
205 return "error: can't read the stderr link.";
208 if (strstr(buf,
"/dev/") !=
NULL) {
210 return "error: stderr is a special file.";
214 FILE *sr = fopen(buf ,
"rb");
216 return "error: can't open the stderr (deleted?).";
220 fseek(sr, 0, SEEK_END);
221 long size = ftell(sr);
227 fseek(sr, from, SEEK_SET);
236 start = strchr(start,
'\n');
250 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.