#include <ProcessMetrics.hpp>
Classes | |
struct | _oldCpu |
Structure to store the old CPU times. More... | |
Public Member Functions | |
ProcessMetrics (std::shared_ptr< std::atomic_flag > checkFlag, const std::shared_ptr< prometheus::Registry > ®) | |
ProcessMetrics (const ProcessMetrics &)=delete | |
Copy constructor. | |
ProcessMetrics (ProcessMetrics &&)=delete | |
Move constructor. | |
ProcessMetrics & | operator= (ProcessMetrics)=delete |
Copy assignment operator. | |
ProcessMetrics & | operator= (ProcessMetrics &&)=delete |
Move assignment operator. | |
~ProcessMetrics () | |
Protected Member Functions | |
double | getCpuUsage () |
std::pair< size_t, size_t > | getDiskIO () |
void | update () |
void | threadRunner () noexcept |
Static Protected Member Functions | |
static long int | getMemoryUsage () |
static long int | getPageFaults () |
static size_t | getThreadCount () |
static size_t | getFileDescriptorCount () |
Static Private Member Functions | |
static size_t | countDirectoryEntries (const std::string &path) |
Private Attributes | |
std::atomic_flag | _shouldStop {false} |
Flag to stop monitoring. | |
std::unique_ptr< std::thread > | _thread |
Thread handler. | |
std::shared_ptr< std::atomic_flag > | _checkFlag |
Runtime check flag. | |
prometheus::Gauge * | _pInitTime |
Pointer to initialization time gauge. | |
prometheus::Gauge * | _pCurrentTime |
Pointer to the current time gauge. | |
prometheus::Gauge * | _pMemory |
Pointer to the memory usage gauge. | |
prometheus::Gauge * | _pPageFaults |
Pointer to the page faults gauge. | |
prometheus::Gauge * | _pCpuUsage |
Pointer to the CPU usage gauge. | |
prometheus::Gauge * | _pDiskRead |
Pointer to the disk read gauge. | |
prometheus::Gauge * | _pDiskWrite |
Pointer to the disk write gauge. | |
prometheus::Gauge * | _pThreadCount |
Pointer to the thread count gauge. | |
prometheus::Gauge * | _pFileDescriptorCount |
Pointer to the file descriptor count gauge. | |
size_t | _oldReadBytes {0} |
Variable to store the old read bytes. | |
size_t | _oldWriteBytes {0} |
Variable to store the old write bytes. | |
clock_t | _oldCpuTime {0} |
Variable to store the old CPU time. | |
Class that provides metrics related to the current process.
Definition at line 14 of file ProcessMetrics.hpp.
ProcessMetrics::ProcessMetrics | ( | std::shared_ptr< std::atomic_flag > | checkFlag, |
const std::shared_ptr< prometheus::Registry > & | reg ) |
Constructs a ProcessMetrics object.
[in] | reg | The Prometheus registry. |
[in] | checkFlag | Runtime check flag |
Definition at line 122 of file ProcessMetrics.cpp.
|
delete |
Copy constructor.
|
delete |
Move constructor.
ProcessMetrics::~ProcessMetrics | ( | ) |
Deconstructs a ProcessMetrics object.
Definition at line 155 of file ProcessMetrics.cpp.
|
staticprivate |
Counts the number of entries in a directory.
[in] | path | The path of the directory. |
Definition at line 12 of file ProcessMetrics.cpp.
|
protected |
Gets the CPU usage of the process.
Definition at line 42 of file ProcessMetrics.cpp.
|
protected |
Gets the disk read and write bytes of the process.
Definition at line 66 of file ProcessMetrics.cpp.
|
staticprotected |
Gets the number of file descriptors in the process.
Definition at line 86 of file ProcessMetrics.cpp.
|
staticprotected |
Gets the memory usage of the process.
Definition at line 28 of file ProcessMetrics.cpp.
|
staticprotected |
Gets the number of page faults of the process.
Definition at line 35 of file ProcessMetrics.cpp.
|
staticprotected |
Gets the number of threads in the process.
Definition at line 84 of file ProcessMetrics.cpp.
|
delete |
Move assignment operator.
|
delete |
Copy assignment operator.
|
protectednoexcept |
Main thread function
Definition at line 101 of file ProcessMetrics.cpp.
|
protected |
Updates the metrics values.
Definition at line 88 of file ProcessMetrics.cpp.
|
private |
Runtime check flag.
Definition at line 18 of file ProcessMetrics.hpp.
|
private |
|
private |
|
private |
|
private |
Pointer to the CPU usage gauge.
Definition at line 24 of file ProcessMetrics.hpp.
|
private |
Pointer to the current time gauge.
Definition at line 21 of file ProcessMetrics.hpp.
|
private |
Pointer to the disk read gauge.
Definition at line 25 of file ProcessMetrics.hpp.
|
private |
Pointer to the disk write gauge.
Definition at line 26 of file ProcessMetrics.hpp.
|
private |
Pointer to the file descriptor count gauge.
Definition at line 28 of file ProcessMetrics.hpp.
|
private |
Pointer to initialization time gauge.
Definition at line 20 of file ProcessMetrics.hpp.
|
private |
Pointer to the memory usage gauge.
Definition at line 22 of file ProcessMetrics.hpp.
|
private |
Pointer to the page faults gauge.
Definition at line 23 of file ProcessMetrics.hpp.
|
private |
Pointer to the thread count gauge.
Definition at line 27 of file ProcessMetrics.hpp.
|
private |
|
private |
Thread handler.
Definition at line 17 of file ProcessMetrics.hpp.