-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathProcessMonitor.h
More file actions
65 lines (49 loc) · 1.5 KB
/
ProcessMonitor.h
File metadata and controls
65 lines (49 loc) · 1.5 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
///
/// \file ProcessMonitor.h
/// \author Adam Wegrzynek <adam.wegrzynek@cern.ch>
///
#ifndef ALICEO2_MONITORING_CORE_PROCESSMONITOR_H
#define ALICEO2_MONITORING_CORE_PROCESSMONITOR_H
#include <atomic>
#include <boost/algorithm/string.hpp>
#include <mutex>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include "Monitoring/Metric.h"
namespace o2
{
/// ALICE O2 Monitoring system
namespace monitoring
{
/// Monitors current process and/or other processes running at the same machien
class ProcessMonitor
{
friend class Monitoring;
public:
/// Prepares externam software commands (ps)
ProcessMonitor();
/// Default destructor
~ProcessMonitor() = default;
/// Generates performance metrics (stored in mPsParams vecotr)
std::vector<Metric> getPidStatus();
/// Generates metrics per network interface: bytesReceived, bytesTransmitted
std::vector<Metric> getNetworkUsage();
private:
/// PIDs that are monitored
unsigned int mPid;
/// options to be passed to PS
std::string mPsCommand;
/// mutex to lock vector of PIDs
std::mutex mVectorPidLock;
/// List of PS params with their types
const std::vector<std::pair<std::string, MetricType>> mPsParams {
{"etime", MetricType::STRING}, {"pcpu", MetricType::DOUBLE}, {"pmem", MetricType::DOUBLE}
};
/// Executes terminal command
std::string exec(const char* cmd);
};
} // namespace monitoring
} // namespace o2
#endif // ALICEO2_MONITORING_CORE_PROCESSMONITOR_H