This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmetrics.h
142 lines (123 loc) · 5.08 KB
/
metrics.h
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//
// metrics.h - header file with functions related to defining and gathering the metrics
//
// 2022-2023 Damian Strojek @damianStrojek
// Piotr Garbowski @dideek
// Jakub Wasniewski @wisnia01
//
// External libraries
#include <string> // string
#ifndef METRICS_H
#define METRICS_H
#define GPROCESSID 1 // PID of process that we are focused on (G stands for global)
struct SystemMetrics {
int processesRunning; // Number of processes in the R state
int processesAll; // Number of all processes
int processesBlocked; // Number of processes waiting for I/O operation to complete
int contextSwitchRate; // Number of context switches per second
int interruptRate; // Number of all interrupts handled per second
SystemMetrics();
void printSystemMetrics();
};
struct ProcessorMetrics {
int timeUser; // Time spent in user space
int timeNice; // Time spent in user with low priority space
int timeSystem; // Time spent in system space
int timeIdle; // Time spent on idle task
int timeIoWait; // Time spent waiting for I/O operation to complete
int timeIRQ; // Interrupt handling time
int timeSoftIRQ; // SoftIRQ handling time
int timeSteal; // Time spent in other OSs in visualization mode
int timeGuest; // Virtual CPU uptime for other OSs under kernel control
int instructionsRetired; // Number of instructions executed by the processor
int cycles; // Number of cycles executed by the processor
float frequencyRelative; // CPU clock frequency in MHz
float unhaltedFrequency; // unhalted CPU clock frequency in MHz
int cacheL2Requests; // L2 cache requests issued by the processor
int cacheL2Misses; // L2 cache misses
int cacheLLCLoads; // Number of cache loads from the Last Level Cache
int cacheLLCStores; // Number of cache stores to the LLC
int cacheLLCLoadMisses; // Number of LLC load misses
float cacheLLCLoadMissRate; // LLC load misses divided by LLC loads
int cacheLLCStoreMisses; // Number of LLC store misses
float cacheLLCStoreMissRate; // LLC store misses divided by LLC stores
ProcessorMetrics();
void printProcessorMetrics();
};
struct InputOutputMetrics {
int processID; // Process ID of a given task
float dataRead; // Data read
float readTime; // Data read time
int readOperationsRate; // Amount of read operations per second
float dataWritten; // Data written
float writeTime; // Data write time
int writeOperationsRate; // Amount of write operations per second
float flushTime; // Flush execution time
float flushOperationsRate; // Amount of flush operations per second
InputOutputMetrics();
void printInputOutputMetrics();
};
struct MemoryMetrics {
float memoryUsed; // RAM used
float memoryCached; // Cache for files read from disk
float swapUsed; // Swap memory used
float swapCached; // Data previously written from memory to disk,
// fetched back and still in the swap file
float memoryActive; // Data used in the last period
float memoryInactive; // Data used before memoryActive
float pageInRate; // Pages read
float pageOutRate; // Pages saved
float pageFaultRate; // No page status
float pageFaultsMajorRate; // Page missing (need to load from disk)
float pageFreeRate; // Page release
float pageActivateRate; // Page activation
float pageDeactivateRate; // Page deactivation
float memoryReadRate; // Reading from memory
float memoryWriteRate; // Writing to memory
float memoryIoRate; // Requests to read/write data from all I/O devices
MemoryMetrics();
void printMemoryMetrics();
};
struct NetworkMetrics {
int receivedData; // All of the packets sent
float receivePacketRate; // packets that are being received in KB/s
int sentData; // All of the packets sent
float sendPacketsRate; // packets that are being sent in KB/s
NetworkMetrics();
void printNetworkMetrics();
};
struct PowerMetrics {
float processorPower; // Power consumed by processor
float memoryPower; // Power consumed by memory
float systemPower; // Power consumed by system overall
float gpuPower; // Power consumed by GPU
float gpuTemperature; // Temperature of the GPU
float gpuFanSpeed; // Fan speed of the GPU
float gpuMemoryTotal; // Total memory available for GPU
float gpuMemoryUsed; // Memory used by GPU
float gpuMemoryFree; // Memory free to use by GPU
float gpuClocksCurrentSM; // Current clocks
float gpuClocksCurrentMemory; // Current clocks memory
PowerMetrics();
void printPowerMetrics();
};
struct AllMetrics {
//std::string nodeTimestamp;
SystemMetrics systemMetrics;
ProcessorMetrics processorMetrics;
InputOutputMetrics inputOutputMetrics;
MemoryMetrics memoryMetrics;
NetworkMetrics networkMetrics;
PowerMetrics powerMetrics;
AllMetrics();
};
// Fetching the metrics into structures
void getSystemMetrics(SystemMetrics&);
void getProcessorMetrics(ProcessorMetrics&);
void getInputOutputMetrics(InputOutputMetrics&);
void getMemoryMetrics(MemoryMetrics&);
void getNetworkMetrics(NetworkMetrics&);
void getPowerMetrics(PowerMetrics&);
// Getting the output from system to string
std::string exec(const char*);
#endif