5 #include <unordered_map>
6 #include "artdaq-utilities/Plugins/MetricData.hh"
104 std::list<std::unique_ptr<MetricData>>
SendMetrics();
109 uint64_t user{0}, nice{0}, system{0}, idle{0}, iowait{0}, irq{0}, softirq{0};
110 uint64_t totalUsage{0}, total{0};
112 cpustat ReadProcStat_();
113 static size_t GetCPUCount_();
115 double nonIdleCPUPercent_;
116 double userCPUPercent_;
117 double systemCPUPercent_;
118 double idleCPUPercent_;
119 double iowaitCPUPercent_;
120 double irqCPUPercent_;
124 uint64_t send_bytes{0}, recv_bytes{0}, send_errs{0}, recv_errs{0};
125 std::chrono::steady_clock::time_point collectionTime;
129 std::unordered_map<std::string, netstat> stats;
130 std::chrono::steady_clock::time_point collectionTime;
132 netstats ReadProcNetDev_();
133 void UpdateNetstat_();
136 struct tms lastProcessCPUTimes_;
137 clock_t lastProcessCPUTime_;
138 netstats thisNetStat_;
139 netstats lastNetStat_;
140 bool sendProcessMetrics_;
141 bool sendSystemMetrics_;
uint64_t GetNetworkTCPRetransSegs()
Return the current number of TCP (total) segments retransmitted, segments
uint64_t GetTotalRAM()
Get the total amount of RAM in the system
uint64_t GetNetworkReceiveErrors(std::string ifname)
Get the number of network receive errors in the last network collection interval (1.0 s)
uint64_t GetNetworkSendBytes(std::string ifname)
Get the amount of data sent to the network in the last network collection interval (1...
uint64_t GetProcessMemUsage()
Get the amount of RAM being used by this process
std::list< std::unique_ptr< MetricData > > SendMetrics()
Send the configured metrics
uint64_t GetNetworkSendErrors(std::string ifname)
Get the number of network send errors in the last network collection interval (1.0 s) ...
Collects metrics from the system, using proc filesystem or kernel API calls
double GetAvailableRAMPercent(bool buffers)
Get the percentage of available RAM
std::list< std::string > GetNetworkInterfaceNames()
Get the names of the local network interfaces.
void GetSystemCPUUsage()
Calculate the system CPU usage percentages
uint64_t GetAvailableRAM()
Get the amount of available RAM in the system
double GetProcessCPUUsagePercent()
Return the current amount of CPU usage for the current process, %
SystemMetricCollector(bool processMetrics, bool systemMetrics)
SystemMetricCollector Constructor
double GetProcessMemUsagePercent()
Get the amount of RAM being used by this process
uint64_t GetNetworkReceiveBytes(std::string ifname)
Get the amount of data received from the network in the last network collection interval (1...
uint64_t GetBufferedRAM()
Get the amount of RAM currently being used for cache