0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StatsSystem.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 #ifndef Common_StatsSystem_h
27 #define Common_StatsSystem_h
28 
30 #include <Common/SystemInfo.h>
31 
32 #include <memory>
33 
34 namespace Hypertable {
35 
43  class StatsSystem : public StatsSerializable {
44  public:
46  enum Category {
47  CPUINFO = 0x0001,
48  CPU = 0x0002,
49  LOADAVG = 0x0004,
50  MEMORY = 0x0008,
51  DISK = 0x0010,
52  SWAP = 0x0020,
53  NETINFO = 0x0040,
54  NET = 0x0080,
55  OSINFO = 0x0100,
56  PROCINFO = 0x0200,
57  PROC = 0x0400,
58  FS = 0x0800,
59  TERMINFO = 0x1000
60  };
61 
65  }
66 
70  StatsSystem(int32_t categories);
71 
77  StatsSystem(int32_t categories, std::vector<String> &dirs);
78 
80  void add_categories(int32_t categories);
81 
83  void add_categories(int32_t categories, std::vector<String> &dirs);
84 
86  void refresh();
87 
89  bool operator==(const StatsSystem &other) const;
90 
92  bool operator!=(const StatsSystem &other) const {
93  return !(*this == other);
94  }
95 
97  struct CpuInfo cpu_info;
98 
101 
104 
107 
110 
113 
116 
118  struct OsInfo os_info;
119 
122 
125 
128 
130  std::vector<struct DiskStat> disk_stat;
131 
133  std::vector<struct FsStat> fs_stat;
134 
135  protected:
137  virtual size_t encoded_length_group(int group) const;
138 
140  virtual void encode_group(int group, uint8_t **bufp) const;
141 
143  virtual void decode_group(int group, uint16_t len, const uint8_t **bufp,
144  size_t *remainp);
145 
146  private:
147  int32_t m_categories;
148  };
149 
150  typedef std::shared_ptr<StatsSystem> StatsSystemPtr;
151 
154 }
155 
156 #endif // Common_StatsSystem_h
Abstract base class for managing serialized statistics.
bool operator==(const StatsSystem &other) const
Equal operator.
Definition: StatsSystem.cc:168
virtual void encode_group(int group, uint8_t **bufp) const
Serializes a statistics group to memory.
Definition: StatsSystem.cc:300
Base class managing serialized statistics.
A structure to retrieve Swapping statistics (pages swapped in/out, aggregate total numbers etc) ...
Definition: SystemInfo.h:156
struct NetInfo net_info
Network information (host name, primary interface, gateway etc)
Definition: StatsSystem.h:112
virtual size_t encoded_length_group(int group) const
Returns the encoded length of a statistics group.
Definition: StatsSystem.cc:225
A structure to retrieve CPU statistics (system wide cpu times, idle time etc).
Definition: SystemInfo.h:66
struct NetStat net_stat
Network statistics (transfer rates, receiving rate etc)
Definition: StatsSystem.h:115
virtual void decode_group(int group, uint16_t len, const uint8_t **bufp, size_t *remainp)
Deserializes a statistics group from memory.
Definition: StatsSystem.cc:427
struct CpuInfo cpu_info
CPU information (vendor, model, cores, cache sizes etc)
Definition: StatsSystem.h:97
struct TermInfo term_info
Terminal information (number of lines, number of columns etc)
Definition: StatsSystem.h:127
A structure to retrieve terminal information (lines, columns etc)
Definition: SystemInfo.h:325
StatsSystem()
Default constructor; creates an empty object.
Definition: StatsSystem.h:63
void refresh()
Refreshes the statistics.
Definition: StatsSystem.cc:141
A structure to retrieve CPU information (vendor, model, speed, number of cores etc.)
Definition: SystemInfo.h:46
Category
All statistics categories that are provided by this class.
Definition: StatsSystem.h:46
A structure to receive process statistics (CPU user time, system time, virtmal machine sizes etc) ...
Definition: SystemInfo.h:271
struct ProcStat proc_stat
Process statistics (CPU user time, system time, vm size etc)
Definition: StatsSystem.h:124
struct ProcInfo proc_info
Process information (pid, user, working directory etc)
Definition: StatsSystem.h:121
Collects, serializes and deserializes system-wide statistics.
Definition: StatsSystem.h:43
A structure to retrieve memory statistics (RAM size, used size, free size etc)
Definition: SystemInfo.h:103
Hypertable definitions
struct MemStat mem_stat
Memory statistics (total size, free space, used etc)
Definition: StatsSystem.h:106
A structure to retrieve network information (host name, primary interface, primary address...
Definition: SystemInfo.h:187
A structure to retrieve load average-statistics.
Definition: SystemInfo.h:89
bool operator!=(const StatsSystem &other) const
Not Equal operator.
Definition: StatsSystem.h:92
struct OsInfo os_info
OS information (name, architecture, version etc)
Definition: StatsSystem.h:118
struct LoadAvgStat loadavg_stat
Load average normalized over number of cores.
Definition: StatsSystem.h:103
std::vector< struct FsStat > fs_stat
Filesystem statistics (free space, used space, aggregate files etc)
Definition: StatsSystem.h:133
struct SwapStat swap_stat
Swapping statistics (page in, page out etc)
Definition: StatsSystem.h:109
void add_categories(int32_t categories)
Adds more categories to the already existing categories.
Definition: StatsSystem.cc:69
std::vector< struct DiskStat > disk_stat
Per-Disk statistics (read-rate, write-rate, etc)
Definition: StatsSystem.h:130
System information and statistics based on libsigar.
A structure to receive process information (pid, user name, exe name, working directory, program arguments etc)
Definition: SystemInfo.h:252
std::shared_ptr< StatsSystem > StatsSystemPtr
Definition: StatsSystem.h:150
A structure to retrieve operating system information (name, version, vendor, architecture) ...
Definition: SystemInfo.h:226
struct CpuStat cpu_stat
CPU statistics (user load, system load, idle etc)
Definition: StatsSystem.h:100
A structure to retrieve network statistics (receiving rate, transmitting rate etc) ...
Definition: SystemInfo.h:204