1 #include "ace/Monitor_Control/Windows_Monitor.h"
3 #if defined (ACE_HAS_WIN32_PDH)
5 #include "ace/Log_Category.h"
7 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
11 namespace Monitor_Control
13 Windows_Monitor::Windows_Monitor (const ACE_TCHAR
*path
)
18 , status_ (ERROR_SUCCESS
)
24 Windows_Monitor::update_i ()
26 PdhCollectQueryData (this->query_
);
27 PDH_FMT_COUNTERVALUE pdh_value
;
29 PdhGetFormattedCounterValue (this->counter_
,
34 this->value_
= pdh_value
.doubleValue
;
38 Windows_Monitor::clear_impl ()
44 Windows_Monitor::init ()
46 /// Create a query and a counter here so it doesn't have
47 /// to be done with each update.
49 this->status_
= ACE_TEXT_PdhOpenQuery (0, 0, &this->query_
);
51 if (ERROR_SUCCESS
!= this->status_
)
53 ACELIB_ERROR ((LM_DEBUG
, ACE_TEXT ("PdhOpenQuery failed\n")));
57 ACE_TEXT_PdhAddCounter (this->query_
,
62 if (ERROR_SUCCESS
!= this->status_
)
64 ACELIB_ERROR ((LM_DEBUG
,
65 ACE_TEXT ("PdhAddCounter %s failed\n"),
66 this->path_
.c_str ()));
72 ACE_END_VERSIONED_NAMESPACE_DECL
74 #endif /* defined (ACE_HAS_WIN32_PDH) */