obmon  1.3.1
 All Classes Functions Variables Typedefs Enumerations Groups Pages
ObSensorSystem.h
1 
7 
9 #pragma once
10 
11 #include <ObSensor.h>
12 
13 #include <iostream>
14 #include <map>
15 #include <string>
16 #include <vector>
17 
18 #pragma clang diagnostic push
19 #pragma clang diagnostic ignored "-Weverything"
20 #include <glibtop.h>
21 #include <glibtop/cpu.h>
22 #include <glibtop/loadavg.h>
23 #include <glibtop/mem.h>
24 #include <glibtop/netlist.h>
25 #include <glibtop/netload.h>
26 #pragma clang diagnostic pop
27 
34 
35 class ObSensorSystem : public ObSensor {
36 public:
37  ObSensorSystem(std::string name = {"sys"});
38  virtual ~ObSensorSystem() override;
39 
40  bool init() override;
41  void process() override;
42  void speed(ObSensor *s1, ObSensor *s2, unsigned int timeout = 1000) override;
43  std::string json(const std::string name = {"static"}) const override;
44 
46  glibtop_cpu cpu() const { return _cpu; }
47 
49  glibtop_mem mem() const { return _mem; }
50 
52  glibtop_netlist netlist() const { return _netlist; }
53 
55  std::vector<glibtop_netload *> netloads() const { return _netloads; }
56 
57  struct DiskInfo; // FWD declaration, so it doesn't look *that* messy
58  std::map<std::string, DiskInfo> disks() const { return diskInfos; }
59 
60  struct DiskInfo {
61  uint64_t majorID = 0;
62  uint64_t minorID = 0;
63  std::string devName;
64 
65  uint64_t rCount = 0;
66  uint64_t rMerged = 0;
67  uint64_t rSectors = 0;
68  uint64_t rTime = 0;
69 
70  uint64_t wCount = 0;
71  uint64_t wMerged = 0;
72  uint64_t wSectors = 0;
73  uint64_t wTime = 0;
74 
75  uint64_t currentIOCount = 0;
76  uint64_t timeIO = 0;
77  uint64_t weightedTimeIO = 0;
78  };
79 
80 private:
81  uint64_t sz_MiB_kiB_(unsigned long long mib) { return mib * 1024; }
82 
83  glibtop *_sysinfo;
84  glibtop_cpu _cpu{};
85  glibtop_mem _mem{};
86  glibtop_loadavg _loadavg{};
87  glibtop_netlist _netlist{};
88  std::vector<glibtop_netload *> _netloads{};
89  std::vector<std::string> _netnames{};
90 
91  std::vector<std::pair<std::string, bool>> allowedDisks{};
92  std::map<std::string, DiskInfo> diskInfos{};
93  std::vector<std::string> allowedNICs{};
94  double maxDiskSpeed = static_cast<double>(sz_MiB_kiB_(100));
95 };
96 
void process() override
Process function.
System Obmon sensor class.
ObSensorSystem(std::string name={"sys"})
uint64_t majorID
Storage device major ID.
glibtop_mem mem() const
returns glibtop_mem
std::vector< std::string > _netnames
list of network names
bool init() override
uint64_t rSectors
Count of sectors read.
glibtop_netlist netlist() const
returns glibtop_netlist
std::string name() const
Returns name of sensor.
Definition: ObSensor.h:38
glibtop * _sysinfo
Sys info from glitop.
void speed(ObSensor *s1, ObSensor *s2, unsigned int timeout=1000) override
Calculate time change (speed)
virtual ~ObSensorSystem() override
std::vector< glibtop_netload * > netloads() const
returns netloads
glibtop_mem _mem
Mem info from glitop.
std::string json(const std::string name={"static"}) const override
uint64_t wTime
Time of sector writing (? NEEDINFO)
uint64_t timeIO
Time total taken by IO ops.
uint64_t wCount
Count of write operations.
std::string devName
Storage device name.
glibtop_cpu _cpu
CPU info from glitop.
glibtop_cpu cpu() const
returns glibtop_cpu
uint64_t weightedTimeIO
Weighted time taken by IO ops (? NEEDINFO)
Base Obmon sensor class.
Definition: ObSensor.h:19
uint64_t currentIOCount
Count of currently running IO ops.
uint64_t rMerged
Count of merged read operations.
glibtop_loadavg _loadavg
Load average info from glibtop.
uint64_t rTime
Time of sector reading (? NEEDINFO)
uint64_t rCount
Count of read operations.
glibtop_netlist _netlist
NetList from glitop.
uint64_t wMerged
Count of merged write operations.
uint64_t minorID
Storage device minor ID.
uint64_t wSectors
Count of sectors written.
std::vector< glibtop_netload * > _netloads
List of netload.