diff options
Diffstat (limited to 'ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp')
-rw-r--r-- | ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp | 105 |
1 files changed, 2 insertions, 103 deletions
diff --git a/ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp b/ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp index 60ca87f76c4..af3bfe97163 100644 --- a/ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp +++ b/ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp @@ -2,10 +2,6 @@ #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) -#if defined (ACE_HAS_KSTAT) -#include <sys/sysinfo.h> -#endif - #if defined (ACE_LINUX) #include "ace/OS_NS_stdio.h" #endif @@ -27,7 +23,7 @@ namespace ACE #if defined (ACE_HAS_WIN32_PDH) , Windows_Monitor (ACE_TEXT("\\Processor(_Total)\\% Processor Time")) #endif -#if defined (ACE_LINUX) || defined (ACE_HAS_KSTAT) +#if defined (ACE_LINUX) , user_ (0) , wait_ (0) , kernel_ (0) @@ -37,10 +33,6 @@ namespace ACE #endif #if defined (ACE_LINUX) , file_ptr_ (0) -#elif defined (ACE_HAS_KSTAT) - , kstats_ (0) - , kstat_ (0) - , kstat_id_ (0) #endif { this->init (); @@ -58,7 +50,7 @@ namespace ACE this->access_kstats (&this->idle_); #endif -#if defined (ACE_LINUX) || defined (ACE_HAS_KSTAT) +#if defined (ACE_LINUX) double delta_idle = this->idle_ - this->prev_idle_; double total = this->user_ + this->wait_ + this->kernel_ + this->idle_; @@ -109,12 +101,6 @@ namespace ACE this->prev_total_ = this->user_ + this->wait_ + this->kernel_ + this->prev_idle_; -#elif defined (ACE_HAS_KSTAT) - /// Stored similarly to Linux, in a system file. - this->access_kstats (&this->prev_idle_); - - this->prev_total_ = - this->user_ + this->wait_ + this->kernel_ + this->prev_idle_; #endif } @@ -160,93 +146,6 @@ namespace ACE ACE_OS::fclose (this->file_ptr_); } #endif - -#if defined (ACE_HAS_KSTAT) - void - CPU_Load_Monitor::access_kstats (unsigned long *which_idle) - { - this->kstats_ = kstat_open (); - - if (this->kstats_ == 0) - { - ACELIB_ERROR ((LM_ERROR, - ACE_TEXT ("opening kstats file failed\n"))); - return; - } - - this->kstat_id_ = this->kstats_->kc_chain_id; - - while (true) - { - this->kernel_ = 0UL; - this->wait_ = 0UL; - this->user_ = 0UL; - (*which_idle) = 0UL; - - /// Unlike Linux's "/proc/stat", there is no entry for total CPU - /// stats, so we have to sum them manually. - for (this->kstat_ = this->kstats_->kc_chain; - this->kstat_ != 0; - this->kstat_ = this->kstat_->ks_next) - { - int result = ACE_OS::strncmp (this->kstat_->ks_name, - "cpu_stat", - ACE_OS::strlen ("cpu_stat")); - - if (result == 0) - { - /// Because the kstat chain can change dynamically, - /// watch the chain ID and restart the walk if the ID - /// differs from what we saw during the walk. The restart - /// is done by breaking from the cycle with kstat_ not 0. - - kid_t kstat_id = kstat_read (this->kstats_, this->kstat_, 0); - - if (kstat_id != this->kstat_id_) - { - break; - } - - cpu_stat_t &kstat_cpu = - *((cpu_stat_t *) this->kstat_->ks_data); - - this->kernel_ += kstat_cpu.cpu_sysinfo.cpu[CPU_KERNEL]; - this->wait_ += kstat_cpu.cpu_sysinfo.cpu[CPU_WAIT]; - this->user_ += kstat_cpu.cpu_sysinfo.cpu[CPU_USER]; - (*which_idle) += kstat_cpu.cpu_sysinfo.cpu[CPU_IDLE]; - } - } - - if (this->kstat_ != 0) - { - /// The ID changed underneath us, so get the new one and - /// start again. - this->kstat_id_ = kstat_chain_update (this->kstats_); - - if (! this->kstat_id_ > 0) - { - ACELIB_ERROR ((LM_ERROR, - ACE_TEXT ("kstat chain update ") - ACE_TEXT ("returned null id\n"))); - return; - } - } - else - { - /// Clean run, exit the WHILE loop. - break; - } - } - - int status = kstat_close (this->kstats_); - - if (status != 0) - { - ACELIB_ERROR ((LM_ERROR, - ACE_TEXT ("closing kstats file failed\n"))); - } - } -#endif } } |