COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
DeviceCpu Class Reference

#include <devicecpu.h>

Collaboration diagram for DeviceCpu:

Public Member Functions

 DeviceCpu ()
 
void stress ()
 
double getLoad ()
 
uint16_t getCpuCount ()
 
uint32_t getUptime ()
 
uint16_t getBootCount ()
 
double getVirtualMemoryTotal ()
 
double getVirtualMemoryUsed ()
 
double getVirtualMemoryFree ()
 
double getVirtualMemoryUsedPercent ()
 
double getPercentUseForCurrentProcess ()
 
string getHostName ()
 
double BytesToKiB (double bytes)
 
double BytesToMiB (double bytes)
 
double BytesToMB (double bytes)
 
double getVirtualMemoryUsedKiB ()
 
double getVirtualMemoryUsedMiB ()
 
double getVirtualMemoryUsedMB ()
 
double getMemoryUsed ()
 
double getMemoryTotal ()
 
double getMemoryUsedKiB ()
 
double getMemoryUsedMiB ()
 
double getMemoryTotalKiB ()
 
double getMemoryTotalMiB ()
 
double getMemoryUsedMB ()
 
double getMemoryTotalMB ()
 
pid_t getPidOf (string processName)
 
pid_t getMemoryUsedOf (string processName)
 
float getPercentCpuOf (string processName)
 
float getPercentMemoryOf (string processName)
 

Public Attributes

double percentUseForCurrentProcess
 
int numProcessors
 
string processName
 
string hostName
 
double memoryUsed
 
double memoryTotal
 
double memoryFree
 
double memoryBuffers
 
double virtualMemoryUsed
 
double virtualMemoryTotal
 
double virtualMemoryFree
 
double load
 

Constructor & Destructor Documentation

DeviceCpu::DeviceCpu ( )
34 {
35 
36 }

Member Function Documentation

void DeviceCpu::stress ( )
756  {
757  for (int i = 0; i< 40000; i++) {
758  double temp = sqrt(i)*i/log(i);
759  temp = sqrt(temp);
760  }
761 }
int i
Definition: rw_test.cpp:37
double DeviceCpu::getLoad ( )
39 {
40 
41 #if defined(COSMOS_LINUX_OS)
42  load = cpuLinux.getLoad1minAverage();
43 #endif
44 
45 #if defined(COSMOS_MAC_OS)
46  load = cpuMac.getLoad1minAverage();
47 #endif
48 
49 #if defined(COSMOS_WIN_OS)
50  load = cpuWin.getLoad() * numProcessors;
51 #endif
52 
53  return load;
54 }
int numProcessors
Definition: devicecpu.h:245
double load
Definition: devicecpu.h:255
uint16_t DeviceCpu::getCpuCount ( )
57 {
58  uint16_t count = 1;
59 #if defined(COSMOS_LINUX_OS)
60  count = cpuLinux.getCpuCount();
61 #endif
62  return count;
63 }
int count
Definition: rw_test.cpp:36
uint32_t DeviceCpu::getUptime ( )
75 {
76  uint32_t count = 1;
77 #if defined(COSMOS_LINUX_OS)
78  count = cpuLinux.getUptime();
79 #endif
80  return count;
81 }
int count
Definition: rw_test.cpp:36
uint16_t DeviceCpu::getBootCount ( )
66 {
67  uint16_t count = 1;
68 #if defined(COSMOS_LINUX_OS)
69  count = cpuLinux.getBootCount();
70 #endif
71  return count;
72 }
int count
Definition: rw_test.cpp:36
double DeviceCpu::getVirtualMemoryTotal ( )
168  {
169 
170 #if defined(COSMOS_LINUX_OS)
171  virtualMemoryTotal = cpuLinux.getVirtualMemoryTotal();
172 #endif
173 
174 #if defined(COSMOS_WIN_OS)
175  ;
176  virtualMemoryTotal = cpuWin.getVirtualMemoryTotal();
177 #endif
178 
179  return virtualMemoryTotal;
180 }
double virtualMemoryTotal
Definition: devicecpu.h:253
double DeviceCpu::getVirtualMemoryUsed ( )
110  {
111 
112 #if defined(COSMOS_LINUX_OS)
113  virtualMemoryUsed = cpuLinux.getVirtualMemoryUsed();
114 #endif
115 
116 #if defined(COSMOS_WIN_OS)
117  virtualMemoryUsed = cpuWin.getVirtualMemoryUsed();
118 #endif
119  return virtualMemoryUsed;
120 
121 }
double virtualMemoryUsed
Definition: devicecpu.h:252
double DeviceCpu::getVirtualMemoryFree ( )
double DeviceCpu::getVirtualMemoryUsedPercent ( )
183  {
184 
185  double virtualMemoryUsedPercent = getVirtualMemoryUsed() / getVirtualMemoryTotal();
186 
187  return virtualMemoryUsedPercent;
188 }
double getVirtualMemoryTotal()
Definition: devicecpu.cpp:168
double getVirtualMemoryUsed()
Definition: devicecpu.cpp:110
double DeviceCpu::getPercentUseForCurrentProcess ( )
191  {
192 
193 #if defined(COSMOS_LINUX_OS)
194  percentUseForCurrentProcess = cpuLinux.getPercentUseForCurrentProcess();
195 #endif
196 
197 #if defined(COSMOS_WIN_OS)
198  // TODO
200 #endif
202 
203 }
double percentUseForCurrentProcess
Definition: devicecpu.h:244
string DeviceCpu::getHostName ( )
206 {
207 #if defined(COSMOS_LINUX_OS)
208  hostName = cpuLinux.getHostName();
209 #endif
210 
211 #if defined(COSMOS_MAC_OS)
212  hostName = cpuMac.getHostName();
213 #endif
214 
215 #if defined(COSMOS_WIN_OS)
216  hostName = cpuWin.getHostName();
217 #endif
218 
219  return hostName;
220 }
string hostName
Definition: devicecpu.h:247
double DeviceCpu::BytesToKiB ( double  bytes)
273 {
274  return bytes/1024.;
275 }
double DeviceCpu::BytesToMiB ( double  bytes)
278 {
279  return bytes/1024./1024.;
280 }
double DeviceCpu::BytesToMB ( double  bytes)
283 {
284  return bytes/1000./1000.;
285 }
double DeviceCpu::getVirtualMemoryUsedKiB ( )
154 {
156 }
double BytesToKiB(double bytes)
Definition: devicecpu.cpp:272
double getVirtualMemoryUsed()
Definition: devicecpu.cpp:110
double DeviceCpu::getVirtualMemoryUsedMiB ( )
159 {
161 }
double BytesToMiB(double bytes)
Definition: devicecpu.cpp:277
double getVirtualMemoryUsed()
Definition: devicecpu.cpp:110
double DeviceCpu::getVirtualMemoryUsedMB ( )
164 {
166 }
double BytesToMB(double bytes)
Definition: devicecpu.cpp:282
double getVirtualMemoryUsed()
Definition: devicecpu.cpp:110
double DeviceCpu::getMemoryUsed ( )
97  {
98 
99 #if defined(COSMOS_LINUX_OS)
100  memoryUsed = cpuLinux.getMemoryUsed();
101 #endif
102 
103 #if defined(COSMOS_WIN_OS)
104  memoryUsed = cpuWin.getVirtualMemoryUsed();
105 #endif
106  return memoryUsed;
107 }
double memoryUsed
Definition: devicecpu.h:248
double DeviceCpu::getMemoryTotal ( )
84  {
85 
86 #if defined(COSMOS_LINUX_OS)
87  memoryTotal = cpuLinux.getMemoryTotal();
88 #endif
89 
90 #if defined(COSMOS_WIN_OS)
91  memoryTotal = cpuWin.getVirtualMemoryTotal();
92 #endif
93  return memoryTotal;
94 }
double memoryTotal
Definition: devicecpu.h:249
double DeviceCpu::getMemoryUsedKiB ( )
124 {
125  return BytesToKiB(getMemoryUsed());
126 }
double BytesToKiB(double bytes)
Definition: devicecpu.cpp:272
double getMemoryUsed()
Definition: devicecpu.cpp:97
double DeviceCpu::getMemoryUsedMiB ( )
129 {
130  return BytesToMiB(getMemoryUsed());
131 }
double getMemoryUsed()
Definition: devicecpu.cpp:97
double BytesToMiB(double bytes)
Definition: devicecpu.cpp:277
double DeviceCpu::getMemoryTotalKiB ( )
139 {
140  return BytesToKiB(getMemoryTotal());
141 }
double BytesToKiB(double bytes)
Definition: devicecpu.cpp:272
double getMemoryTotal()
Definition: devicecpu.cpp:84
double DeviceCpu::getMemoryTotalMiB ( )
144 {
145  return BytesToMiB(getMemoryTotal());
146 }
double getMemoryTotal()
Definition: devicecpu.cpp:84
double BytesToMiB(double bytes)
Definition: devicecpu.cpp:277
double DeviceCpu::getMemoryUsedMB ( )
134 {
135  return BytesToMB(getMemoryUsed());
136 }
double getMemoryUsed()
Definition: devicecpu.cpp:97
double BytesToMB(double bytes)
Definition: devicecpu.cpp:282
double DeviceCpu::getMemoryTotalMB ( )
149 {
150  return BytesToMB(getMemoryTotal());
151 }
double BytesToMB(double bytes)
Definition: devicecpu.cpp:282
double getMemoryTotal()
Definition: devicecpu.cpp:84
pid_t DeviceCpu::getPidOf ( string  processName)
223 {
224 #if defined(COSMOS_LINUX_OS)
225  return cpuLinux.getPidOf(processName);
226 #endif
227 
228 #if defined(COSMOS_WIN_OS)
229  return cpuWin.getPidOf(processName);
230 #endif
231 
232 }
string processName
Definition: devicecpu.h:246
pid_t DeviceCpu::getMemoryUsedOf ( string  processName)
235 {
236 #if defined(COSMOS_LINUX_OS)
237  return cpuLinux.getMemoryUsedOf(processName);
238 #endif
239 
240 #if defined(COSMOS_WIN_OS)
241  // return cpuWin.getMemoryUsedOf(processName);
242 #endif
243 
244  return -1;
245 }
string processName
Definition: devicecpu.h:246
float DeviceCpu::getPercentCpuOf ( string  processName)
248 {
249 #if defined(COSMOS_LINUX_OS)
250  return cpuLinux.getPercentCpuOf(processName);
251 #endif
252 
253 #if defined(COSMOS_WIN_OS)
254  // return cpuWin.getPercentCpuOf(processName);
255 #endif
256  return 0.;
257 }
string processName
Definition: devicecpu.h:246
float DeviceCpu::getPercentMemoryOf ( string  processName)
260 {
261 #if defined(COSMOS_LINUX_OS)
262  return cpuLinux.getPercentMemoryOf(processName);
263 #endif
264 
265 #if defined(COSMOS_WIN_OS)
266  // return cpuWin.getPercentMemoryOf(processName);
267 #endif
268 
269  return 0.;
270 }
string processName
Definition: devicecpu.h:246

Member Data Documentation

double DeviceCpu::percentUseForCurrentProcess
int DeviceCpu::numProcessors
string DeviceCpu::processName
string DeviceCpu::hostName
double DeviceCpu::memoryUsed
double DeviceCpu::memoryTotal
double DeviceCpu::memoryFree
double DeviceCpu::memoryBuffers
double DeviceCpu::virtualMemoryUsed
double DeviceCpu::virtualMemoryTotal
double DeviceCpu::virtualMemoryFree
double DeviceCpu::load

The documentation for this class was generated from the following files: