1 #include "ace/Monitor_Control/Memory_Usage_Monitor.h"
3 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
5 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
9 namespace Monitor_Control
11 const char* Memory_Usage_Monitor::default_name_
=
12 "OS/Memory/TotalUsage";
14 Memory_Usage_Monitor::Memory_Usage_Monitor (const char* name
)
15 : Monitor_Base (name
, Monitor_Control_Types::MC_NUMBER
)
16 #if defined (ACE_HAS_WIN32_PDH)
17 , Windows_Monitor (ACE_TEXT ("\\Memory\\% Committed Bytes In Use"))
23 Memory_Usage_Monitor::update ()
25 #if defined (ACE_HAS_WIN32_PDH)
27 this->receive (this->value_
);
28 #elif defined (ACE_HAS_LINUX_SYSINFO)
29 if (::sysinfo (&this->sysinfo_
) != 0)
31 ACELIB_ERROR ((LM_ERROR
,
32 ACE_TEXT ("Memory usage - sysinfo() failed\n")));
36 double used_ram
= this->sysinfo_
.totalram
- this->sysinfo_
.freeram
;
37 double percent_mem_usage
= used_ram
/ this->sysinfo_
.totalram
* 100.0;
39 this->receive (percent_mem_usage
);
44 Memory_Usage_Monitor::default_name ()
46 return Memory_Usage_Monitor::default_name_
;
50 Memory_Usage_Monitor::clear_i ()
52 #if defined (ACE_HAS_WIN32_PDH)
56 this->Monitor_Base::clear_i ();
61 ACE_END_VERSIONED_NAMESPACE_DECL
63 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */