MStatisticsSample.h
1 /*****************************************************************************
2  **
3  ** Header file for Muster API Statistics sample object
4  **
5  ** Name : MStatisticsSample.h
6  ** Author : Leonardo Bernardini
7 ** Version : Alpha 9.0 Wed May 17th 2017
8  **
9  ** Copyright 2000-2017, Virtual Vertex
10  ** All Rights Reserved.
11  **
12  ** This file contains UNPUBLISHED PROPRIETARY SOURCE CODE.
13  ** The contents of this file may not be disclosed to third parties, copied
14  ** or duplicated in any form, in whole or in part, without the prior written
15  ** permission of the author.
16  **
17  *****************************************************************************/
18 #ifndef MSTATISTICSSAMPLE_H
19 #define MSTATISTICSSAMPLE_H
20 
21 #ifdef WIN32
22 // Windows definitions
23 #ifdef MCLIENTLIB_EXPORTS
24 #define MCLIENTLIB_API __declspec(dllexport)
25 #else
26 #define MCLIENTLIB_API __declspec(dllimport)
27 #endif
28 #else
29 
30 #ifndef MCLIENTLIB_EXPORTS
31 #ifdef LINUX
32 #define MCLIENTLIB_API
33 #else
34 #define MCLIENTLIB_API
35 #endif
36 #else
37 #define MCLIENTLIB_API
38 #endif
39 #endif
40 
41 
42 // Disable STL Export warning, member is private, we don't need direct access from the DLL client
43 #if defined(_WIN32)
44 #pragma warning(disable: 4251)
45 #endif // _WIN32
46 
47 #include <string>
48 #include <list>
49 #include <vector>
50 
51 namespace MClientLib {
52 
53 
55 #ifdef WIN32
56  typedef unsigned long long int mRamCounterType;
57  typedef __int64 mDiskspaceCounterType;
58 #else
59 #ifdef MAC
60  typedef u_int64_t mRamCounterType;
61  typedef u_int64_t mDiskspaceCounterType;
62 #else
63  typedef size_t mRamCounterType;
64  typedef size_t mDiskspaceCounterType;
65 #endif
66 #endif
67 
79  class MCLIENTLIB_API MStatisticsSample {
80  // Class variables are protected to allow friendship inside the Dispatcher for directly counters access
81  protected:
83  long id;
84  long long sampleTime;
85  int connectedNodes;
86  int connectedManagements;
87  int connectedNotificators;
88  int activeWebSessions;
89  int activeWebConnections;
90  int activeWebSSLConnections;
91  int usedNodes;
92  int pausedNodes;
93  int idleNodes;
94  int unavailableNodes;
95  double managementInKbs;
96  double managementOutKbs;
97  double notificatorsInKbs;
98  double notificatorsOutKbs;
99  double nodesInKbs;
100  double nodesOutKbs;
101  double webInKbs;
102  double webOutKbs;
103 
104  unsigned long long int managementsInBytes;
105  unsigned long long int managementsOutBytes;
106  unsigned long long int nodesInBytes;
107  unsigned long long int nodesOutBytes;
108  unsigned long long int notificatorsInBytes;
109  unsigned long long int notificatorsOutBytes;
110  unsigned long long int webInBytes;
111  unsigned long long int webOutBytes;
112 
113  double cpuProcessUsage;
114  std::vector<double> cpuUsages;
115  mRamCounterType totalRamAmount;
116  mRamCounterType usedRam;
117  mRamCounterType totalSwapAmount;
118  mRamCounterType swapUsage;
119  double usedRamPercent;
120  double usedSwapPercent;
121  double usedRamByProcessPercent;
122 
123  std::vector<std::string> nicNames;
124  std::vector<std::string> disksNames;
125  std::vector<double> nicBandwidth;
126  std::vector<unsigned long long> nicSentBytes;
127  std::vector<unsigned long long> nicReadBytes;
128  std::vector<double> diskReadUsage;
129  std::vector<double> diskWriteUsage;
130 
131  std::string encodedProcessorsUsage;
132  std::string encodedRamUsage;
133  std::string encodedNicUsage;
134  std::string encodedDisksUsage;
137  public:
139  virtual ~MStatisticsSample();
141  void reset();
143  long getId();
144  long long getSampleTime();
145  int getConnectedNodes();
146  int getConnectedManagements();
147  int getConnectedNotificators();
148  int getActiveWebSessions();
149  int getActiveWebConnections();
150  int getActiveWebSSLConnections();
151  int getUsedNodes();
152  int getPausedNodes();
153  int getIdleNodes();
154  int getUnavailableNodes();
155  double getTotalInKbs();
156  double getTotalOutKbs();
157  double getManagementInKbs();
158  double getManagementOutKbs();
159  double getNotificatorsInKbs();
160  double getNotificatorsOutKbs();
161  double getNodesInKbs();
162  double getNodesOutKbs();
163  double getWebInKbs();
164  double getWebOutKbs();
165  unsigned long long int getManagementsInBytes();
166  unsigned long long int getManagementsOutBytes();
167  unsigned long long int getNodesInBytes();
168  unsigned long long int getNodesOutBytes();
169  unsigned long long int getNotificatorsInBytes();
170  unsigned long long int getNotificatorsOutBytes();
171  unsigned long long int getWebInBytes();
172  unsigned long long int getWebOutBytes();
173  const std::string& getEncodedProcessorsUsage();
174  const std::string& getEncodedRamUsage();
175  const std::string& getEncodedNicUsage();
176  const std::string& getEncodedDisksUsage();
178  const std::vector<double>& getCpuUsages();
179  double getCpuProcessUsage();
180  mRamCounterType getTotalRamAmount();
181  mRamCounterType getUsedRam();
182  mRamCounterType getTotalSwapAmount();
183  mRamCounterType getSwapUsage();
184  double getUsedRamPercent();
185  double getUsedSwapPercent();
186  double getUsedRamByProcessPercent();
187  const std::vector<std::string>& getNicNames();
188  const std::vector<std::string>& getDisksNames();
189  const std::vector<double>& getNicBandwidth();
190  const std::vector<unsigned long long>& getNicSentBytes();
191  const std::vector<unsigned long long>& getNicReadBytes();
192  const std::vector<double>& getDiskReadUsage();
193  const std::vector<double>& getDiskWriteUsage();
195  void setId(long id );
196  void setSampleTime(long long time );
197  void setConnectedNodes(int amount );
198  void setConnectedManagements(int amount );
199  void setConnectedNotificators(int amount );
200  void setActiveWebSessions(int amount );
201  void setActiveWebConnections(int amount );
202  void setActiveWebSSLConnections(int amount );
203  void setUsedNodes(int amount );
204  void setPausedNodes(int amount );
205  void setIdleNodes(int amount );
206  void setUnavailableNodes(int amount );
207  void setManagementInKbs(double amount );
208  void setManagementOutKbs(double amount );
209  void setNotificatorsInKbs(double amount );
210  void setNotificatorsOutKbs(double amount );
211  void setNodesInKbs(double amount );
212  void setNodesOutKbs(double amount );
213  void setWebInKbs(double amount );
214  void setWebOutKbs(double amount );
215  void setManagementsInBytes(unsigned long long int amount );
216  void setManagementsOutBytes(unsigned long long int amount );
217  void setNodesInBytes(unsigned long long int amount );
218  void setNodesOutBytes(unsigned long long int amount );
219  void setNotificatorsInBytes(unsigned long long int amount );
220  void setNotificatorsOutBytes(unsigned long long int amount );
221  void setWebInBytes(unsigned long long int amount );
222  void setWebOutBytes(unsigned long long int amount );
223  void setEncodedProcessorsUsage(const std::string& processorsUsage );
224  void setEncodedRamUsage(const std::string& ramUsage );
225  void setEncodedNicUsage(const std::string& nicUsage );
226  void setEncodedDisksUsage(const std::string& disksUsage );
229  virtual bool Unmarshall(const std::vector<std::string>& items);
230  virtual std::string Marshall();
232  };
233 
235 }
236 
237 #endif
Class holding a statistics sample.