-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocessstatreader.h
More file actions
70 lines (45 loc) · 1.78 KB
/
processstatreader.h
File metadata and controls
70 lines (45 loc) · 1.78 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
66
67
68
69
70
#ifndef PRSTATREADER_H
#define PRSTATREADER_H
#include <QObject>
#include <QString>
#include "StatReader.h"
#include <libnethogs.h>
namespace StatTypes{
struct ProcessStat{
int64_t read_bytes=0; //bytes read from the underlyling block layer
int64_t write_bytes=0; //bytes written to the underlying block layer
double cpuTimeSec=0;
};
struct ProcessData{
int pid = -1; //!< pid of the process
QString user = "";
double currentReadKiBsDiskData =0;
double currentWriteKiBsDiskData=0;
double currentReadKiBsNetData=0;
double currentWriteKiBsNetData=0;
double currentMemKiB=0;
double currentCPUPct=0;
QString name = " ";
ProcessStat previousStats; //from previous time timepoint
ProcessStat currentStats;
bool firstIteration = true; // must be used to ensure no overflow on first timeinterval
};
}
class ProcessStatReader: public QObject, public StatReader<StatTypes::ProcessData>
{
Q_OBJECT
public:
ProcessStatReader(QObject *parent = nullptr); //!< cosntructor, intialises the class, should determine how many disk there are etc...
~ProcessStatReader();
bool noEthDeviceErr = false;
bool noRootPriv = false;
void measure_main_loop(); //!< collects data for all disk every 100ms, runs until m_quit ist true
signals:
void data_ready();
private:
friend void nethogsCallBack(int action, NethogsMonitorRecord const *data);
std::thread nethogsT;
void update_process_list();
StatTypes::ProcessData* find_pid_in_data(int pid); //!< looks for supplied disk name in data vector, if not foudn return nullptr
};
#endif // DISKSTATREADER_H