-
Notifications
You must be signed in to change notification settings - Fork 0
/
interrupts.cpp
47 lines (43 loc) · 1.03 KB
/
interrupts.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <unistd.h>
#include <algorithm>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/trim_all.hpp>
#include "interrupts.hpp"
using namespace std;
using namespace boost::algorithm;
using namespace boost::program_options;
void init_interrupts_logger(variables_map& vm,
vector<shared_ptr<global_stats_logger> >& loggers)
{
string output = vm["output"].as<string>();
int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
int nintrs = 0;
string header;
ifstream interrupts("/proc/interrupts");
string line;
getline(interrupts, line);
while(getline(interrupts, line)) {
vector<string> cols;
trim_all(line);
split(cols, line, is_any_of(" "));
if (cols[0] == "ERR:")
break;
header += cols[0] + ",";
nintrs++;
}
shared_ptr<global_stats_logger> logger(
new global_stats_logger(
"/proc/interrupts",
output + "/interrupts%d.csv",
1,
nintrs,
1,
ncpus,
header,
EMPTY_VECTOR,
true,
PF_DIRECTION_COL
));
loggers.push_back(logger);
}