diff options
Diffstat (limited to 'ACE/ace/Monitor_Control')
17 files changed, 20 insertions, 488 deletions
diff --git a/ACE/ace/Monitor_Control/Bytes_Received_Monitor.cpp b/ACE/ace/Monitor_Control/Bytes_Received_Monitor.cpp index 9ed53f08b30..9524a483c64 100644 --- a/ACE/ace/Monitor_Control/Bytes_Received_Monitor.cpp +++ b/ACE/ace/Monitor_Control/Bytes_Received_Monitor.cpp @@ -16,12 +16,10 @@ namespace ACE #if defined (ACE_HAS_WIN32_PDH) , Windows_Multi_Instance_Monitor ( ACE_TEXT ("\\Network Interface(*)\\Bytes Received/sec")) -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) , Linux_Network_Interface_Monitor ( " %*[^:]: %lu %*u %*u %*u %*u %*u %*u %*u %*u %*u") /// Scan format for /proc/net/dev -#elif defined (ACE_HAS_KSTAT) - , Solaris_Network_Interface_Monitor (ACE_TEXT ("rbytes")) #elif defined (__NetBSD__) || defined (__OpenBSD__) , BSD_Network_Interface_Monitor (ACE_TEXT ("ibytes")) #elif defined (__FreeBSD__) || defined (__Lynx__) diff --git a/ACE/ace/Monitor_Control/Bytes_Received_Monitor.h b/ACE/ace/Monitor_Control/Bytes_Received_Monitor.h index cecc79da264..de3158513d3 100644 --- a/ACE/ace/Monitor_Control/Bytes_Received_Monitor.h +++ b/ACE/ace/Monitor_Control/Bytes_Received_Monitor.h @@ -23,10 +23,8 @@ #if defined (ACE_HAS_PDH_H) && !defined (ACE_LACKS_PDH_H) #include "ace/Monitor_Control/Windows_Multi_Instance_Monitor.h" -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) #include "ace/Monitor_Control/Linux_Network_Interface_Monitor.h" -#elif defined (ACE_HAS_KSTAT) -#include "ace/Monitor_Control/Solaris_Network_Interface_Monitor.h" #elif defined (__FreeBSD__) || defined (__Lynx__) #include "ace/Monitor_Control/FreeBSD_Network_Interface_Monitor.h" #elif defined (__NetBSD__) || defined (__OpenBSD__) @@ -52,10 +50,8 @@ namespace ACE : public Monitor_Base #if defined (ACE_HAS_WIN32_PDH) , public Windows_Multi_Instance_Monitor -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) , public Linux_Network_Interface_Monitor -#elif defined (ACE_HAS_KSTAT) - , public Solaris_Network_Interface_Monitor #elif defined (__NetBSD__) || defined (__OpenBSD__) , public BSD_Network_Interface_Monitor #elif defined (__FreeBSD__) || defined (__Lynx__) diff --git a/ACE/ace/Monitor_Control/Bytes_Sent_Monitor.cpp b/ACE/ace/Monitor_Control/Bytes_Sent_Monitor.cpp index 98a05b365ed..b196f2f01f5 100644 --- a/ACE/ace/Monitor_Control/Bytes_Sent_Monitor.cpp +++ b/ACE/ace/Monitor_Control/Bytes_Sent_Monitor.cpp @@ -16,12 +16,10 @@ namespace ACE #if defined (ACE_HAS_WIN32_PDH) , Windows_Multi_Instance_Monitor ( ACE_TEXT ("\\Network Interface(*)\\Bytes Sent/sec")) -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) , Linux_Network_Interface_Monitor ( " %*[^:]: %*u %*u %*u %*u %*u %*u %*u %*u %lu %*u") /// Scan format for /proc/net/dev -#elif defined (ACE_HAS_KSTAT) - , Solaris_Network_Interface_Monitor (ACE_TEXT ("obytes")) #elif defined (__FreeBSD__) || defined (__Lynx__) , FreeBSD_Network_Interface_Monitor (ACE_TEXT ("obytes")) #elif defined (__NetBSD__) || defined (__OpenBSD__) diff --git a/ACE/ace/Monitor_Control/Bytes_Sent_Monitor.h b/ACE/ace/Monitor_Control/Bytes_Sent_Monitor.h index 132b6d74004..8672d6749bf 100644 --- a/ACE/ace/Monitor_Control/Bytes_Sent_Monitor.h +++ b/ACE/ace/Monitor_Control/Bytes_Sent_Monitor.h @@ -23,10 +23,8 @@ #if defined (ACE_HAS_PDH_H) && !defined (ACE_LACKS_PDH_H) #include "ace/Monitor_Control/Windows_Multi_Instance_Monitor.h" -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) #include "ace/Monitor_Control/Linux_Network_Interface_Monitor.h" -#elif defined (ACE_HAS_KSTAT) -#include "ace/Monitor_Control/Solaris_Network_Interface_Monitor.h" #elif defined (__FreeBSD__) || defined (__Lynx__) #include "ace/Monitor_Control/FreeBSD_Network_Interface_Monitor.h" #elif defined (__NetBSD__) || defined (__OpenBSD__) @@ -52,10 +50,8 @@ namespace ACE : public Monitor_Base #if defined (ACE_HAS_WIN32_PDH) , public Windows_Multi_Instance_Monitor -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) , public Linux_Network_Interface_Monitor -#elif defined (ACE_HAS_KSTAT) - , public Solaris_Network_Interface_Monitor #elif defined (__NetBSD__) || defined (__OpenBSD__) , public BSD_Network_Interface_Monitor #elif defined (__FreeBSD__) || defined (__Lynx__) 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 } } diff --git a/ACE/ace/Monitor_Control/CPU_Load_Monitor.h b/ACE/ace/Monitor_Control/CPU_Load_Monitor.h index 037cb5d19b2..f286478039b 100644 --- a/ACE/ace/Monitor_Control/CPU_Load_Monitor.h +++ b/ACE/ace/Monitor_Control/CPU_Load_Monitor.h @@ -23,8 +23,6 @@ #if defined (ACE_HAS_PDH_H) && !defined (ACE_LACKS_PDH_H) #include "ace/Monitor_Control/Windows_Monitor.h" -#elif defined (ACE_HAS_KSTAT) -#include "ace/os_include/os_kstat.h" #endif #include "ace/Monitor_Control/Monitor_Control_export.h" @@ -67,15 +65,11 @@ namespace ACE void access_proc_stat (unsigned long *which_idle); #endif -#if defined (ACE_HAS_KSTAT) - void access_kstats (unsigned long *which_idle); -#endif - private: static const char* default_name_; - /// Common to Linux and Solaris implementations. -#if defined (ACE_LINUX) || defined (ACE_HAS_KSTAT) + /// Linux implementation +#if defined (ACE_LINUX) unsigned long user_; unsigned long wait_; unsigned long kernel_; @@ -86,10 +80,6 @@ namespace ACE #if defined (ACE_LINUX) FILE *file_ptr_; char buf_[1024]; -#elif defined (ACE_HAS_KSTAT) - kstat_ctl_t *kstats_; - kstat_t *kstat_; - kid_t kstat_id_; #endif }; } diff --git a/ACE/ace/Monitor_Control/Linux_Network_Interface_Monitor.cpp b/ACE/ace/Monitor_Control/Linux_Network_Interface_Monitor.cpp index b0534ca00be..1ba3229d9e7 100644 --- a/ACE/ace/Monitor_Control/Linux_Network_Interface_Monitor.cpp +++ b/ACE/ace/Monitor_Control/Linux_Network_Interface_Monitor.cpp @@ -1,6 +1,6 @@ #include "ace/Monitor_Control/Linux_Network_Interface_Monitor.h" -#if defined (ACE_LINUX) || defined (AIX) +#if defined (ACE_LINUX) #include "ace/Log_Category.h" #include "ace/OS_NS_stdio.h" @@ -119,4 +119,4 @@ namespace ACE ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* defined (ACE_LINUX) || defined (AIX) */ +#endif /* defined (ACE_LINUX) */ diff --git a/ACE/ace/Monitor_Control/Linux_Network_Interface_Monitor.h b/ACE/ace/Monitor_Control/Linux_Network_Interface_Monitor.h index 5622c7138f3..e60e8c5fcad 100644 --- a/ACE/ace/Monitor_Control/Linux_Network_Interface_Monitor.h +++ b/ACE/ace/Monitor_Control/Linux_Network_Interface_Monitor.h @@ -21,7 +21,7 @@ #include "ace/Monitor_Control/Monitor_Control_export.h" -#if defined (ACE_LINUX) || defined (AIX) +#if defined (ACE_LINUX) ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -67,7 +67,7 @@ namespace ACE ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* defined (ACE_LINUX) || defined (AIX) */ +#endif /* defined (ACE_LINUX) */ #include /**/ "ace/post.h" diff --git a/ACE/ace/Monitor_Control/Memory_Usage_Monitor.cpp b/ACE/ace/Monitor_Control/Memory_Usage_Monitor.cpp index 49593fee95c..ab288a05dfa 100644 --- a/ACE/ace/Monitor_Control/Memory_Usage_Monitor.cpp +++ b/ACE/ace/Monitor_Control/Memory_Usage_Monitor.cpp @@ -1,7 +1,3 @@ -#if defined (ACE_HAS_KSTAT) -#include <sys/sysinfo.h> -#endif - #include "ace/Monitor_Control/Memory_Usage_Monitor.h" #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) @@ -41,15 +37,6 @@ namespace ACE double percent_mem_usage = used_ram / this->sysinfo_.totalram * 100.0; this->receive (percent_mem_usage); -#elif defined (ACE_HAS_KSTAT) - unsigned long page_size = sysconf (_SC_PAGE_SIZE); - unsigned long total = sysconf (_SC_PHYS_PAGES) * page_size; - unsigned long free = sysconf (_SC_AVPHYS_PAGES) * page_size; - - double used = total - free; - double percent_mem_usage = used / total * 100.0; - - this->receive (percent_mem_usage); #endif } diff --git a/ACE/ace/Monitor_Control/Monitor_Control.mpc b/ACE/ace/Monitor_Control/Monitor_Control.mpc index 11366c50ada..5073b019163 100644 --- a/ACE/ace/Monitor_Control/Monitor_Control.mpc +++ b/ACE/ace/Monitor_Control/Monitor_Control.mpc @@ -2,7 +2,6 @@ project(Monitor_Control) : acelib, ace_etcl_parser, ace_output, install { dynamicflags += MONITOR_CONTROL_BUILD_DLL sharedname = ACE_Monitor_Control - avoids += wince Source_Files { Auto_Update_Starter.cpp @@ -21,7 +20,6 @@ project(Monitor_Control) : acelib, ace_etcl_parser, ace_output, install { Num_Threads_Monitor.cpp Packets_Received_Monitor.cpp Packets_Sent_Monitor.cpp - Solaris_Network_Interface_Monitor.cpp Windows_Monitor.cpp Windows_Multi_Instance_Monitor.cpp } diff --git a/ACE/ace/Monitor_Control/Num_Threads_Monitor.h b/ACE/ace/Monitor_Control/Num_Threads_Monitor.h index 422a71c79ea..7a20d2d0b78 100644 --- a/ACE/ace/Monitor_Control/Num_Threads_Monitor.h +++ b/ACE/ace/Monitor_Control/Num_Threads_Monitor.h @@ -23,14 +23,6 @@ #if defined (ACE_HAS_PDH_H) && !defined (ACE_LACKS_PDH_H) #include "ace/Monitor_Control/Windows_Monitor.h" -#elif defined (ACE_HAS_KSTAT) -/// There is apparently no way to query the number of threads on the -/// Solaris platform. The only benchmark I've seen had to put hooks -/// in the thread creation functions to keep track of the highest -/// thread ID, then check all the IDs less than that to see if the -/// threads still exist. Since we don't have that option in this -/// framework, which is to be used by existing applications, this -/// particular OS monitor is left unimplemented on Solaris. #endif #include "ace/Monitor_Control/Monitor_Control_export.h" diff --git a/ACE/ace/Monitor_Control/Packets_Received_Monitor.cpp b/ACE/ace/Monitor_Control/Packets_Received_Monitor.cpp index c01091eacce..4d222b86514 100644 --- a/ACE/ace/Monitor_Control/Packets_Received_Monitor.cpp +++ b/ACE/ace/Monitor_Control/Packets_Received_Monitor.cpp @@ -16,12 +16,10 @@ namespace ACE #if defined (ACE_HAS_WIN32_PDH) , Windows_Multi_Instance_Monitor ( ACE_TEXT ("\\Network Interface(*)\\Packets Received/sec")) -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) , Linux_Network_Interface_Monitor ( " %*[^:]: %*u %lu %*u %*u %*u %*u %*u %*u %*u %*u") /// Scan format for /proc/net/dev -#elif defined (ACE_HAS_KSTAT) - , Solaris_Network_Interface_Monitor (ACE_TEXT ("ipackets")) #elif defined (__FreeBSD__) || defined (__Lynx__) , FreeBSD_Network_Interface_Monitor (ACE_TEXT ("ipackets")) #elif defined (__NetBSD__) || defined (__OpenBSD__) diff --git a/ACE/ace/Monitor_Control/Packets_Received_Monitor.h b/ACE/ace/Monitor_Control/Packets_Received_Monitor.h index d7f80a1491d..d0338dfde6b 100644 --- a/ACE/ace/Monitor_Control/Packets_Received_Monitor.h +++ b/ACE/ace/Monitor_Control/Packets_Received_Monitor.h @@ -23,10 +23,8 @@ #if defined (ACE_HAS_PDH_H) && !defined (ACE_LACKS_PDH_H) #include "ace/Monitor_Control/Windows_Multi_Instance_Monitor.h" -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) #include "ace/Monitor_Control/Linux_Network_Interface_Monitor.h" -#elif defined (ACE_HAS_KSTAT) -#include "ace/Monitor_Control/Solaris_Network_Interface_Monitor.h" #elif defined (__FreeBSD__) || defined (__Lynx__) #include "ace/Monitor_Control/FreeBSD_Network_Interface_Monitor.h" #elif defined (__NetBSD__) || defined (__OpenBSD__) @@ -52,10 +50,8 @@ namespace ACE : public Monitor_Base #if defined (ACE_HAS_WIN32_PDH) , public Windows_Multi_Instance_Monitor -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) , public Linux_Network_Interface_Monitor -#elif defined (ACE_HAS_KSTAT) - , public Solaris_Network_Interface_Monitor #elif defined (__NetBSD__) || defined (__OpenBSD__) , public BSD_Network_Interface_Monitor #elif defined (__FreeBSD__) || defined (__Lynx__) diff --git a/ACE/ace/Monitor_Control/Packets_Sent_Monitor.cpp b/ACE/ace/Monitor_Control/Packets_Sent_Monitor.cpp index fc880ed7ae0..5c3046c0e3e 100644 --- a/ACE/ace/Monitor_Control/Packets_Sent_Monitor.cpp +++ b/ACE/ace/Monitor_Control/Packets_Sent_Monitor.cpp @@ -16,12 +16,10 @@ namespace ACE #if defined (ACE_HAS_WIN32_PDH) , Windows_Multi_Instance_Monitor ( ACE_TEXT ("\\Network Interface(*)\\Packets Sent/sec")) -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) , Linux_Network_Interface_Monitor ( " %*[^:]: %*u %*u %*u %*u %*u %*u %*u %*u %*u %lu") /// Scan format for /proc/net/dev -#elif defined (ACE_HAS_KSTAT) - , Solaris_Network_Interface_Monitor (ACE_TEXT ("opackets")) #elif defined (__NetBSD__) || defined (__OpenBSD__) , BSD_Network_Interface_Monitor (ACE_TEXT ("opackets")) #elif defined (__FreeBSD__) || defined (__Lynx__) diff --git a/ACE/ace/Monitor_Control/Packets_Sent_Monitor.h b/ACE/ace/Monitor_Control/Packets_Sent_Monitor.h index c547434b46a..85de0ca1d63 100644 --- a/ACE/ace/Monitor_Control/Packets_Sent_Monitor.h +++ b/ACE/ace/Monitor_Control/Packets_Sent_Monitor.h @@ -23,10 +23,8 @@ #if defined (ACE_HAS_PDH_H) && !defined (ACE_LACKS_PDH_H) #include "ace/Monitor_Control/Windows_Multi_Instance_Monitor.h" -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) #include "ace/Monitor_Control/Linux_Network_Interface_Monitor.h" -#elif defined (ACE_HAS_KSTAT) -#include "ace/Monitor_Control/Solaris_Network_Interface_Monitor.h" #elif defined (__FreeBSD__) || defined (__Lynx__) #include "ace/Monitor_Control/FreeBSD_Network_Interface_Monitor.h" #elif defined (__NetBSD__) || defined (__OpenBSD__) @@ -52,10 +50,8 @@ namespace ACE : public Monitor_Base #if defined (ACE_HAS_WIN32_PDH) , public Windows_Multi_Instance_Monitor -#elif defined (ACE_LINUX) || defined (AIX) +#elif defined (ACE_LINUX) , public Linux_Network_Interface_Monitor -#elif defined (ACE_HAS_KSTAT) - , public Solaris_Network_Interface_Monitor #elif defined (__NetBSD__) || defined (__OpenBSD__) , public BSD_Network_Interface_Monitor #elif defined (__FreeBSD__) || defined (__Lynx__) diff --git a/ACE/ace/Monitor_Control/Solaris_Network_Interface_Monitor.cpp b/ACE/ace/Monitor_Control/Solaris_Network_Interface_Monitor.cpp deleted file mode 100644 index a3e09a8afa2..00000000000 --- a/ACE/ace/Monitor_Control/Solaris_Network_Interface_Monitor.cpp +++ /dev/null @@ -1,221 +0,0 @@ -#include "ace/Monitor_Control/Solaris_Network_Interface_Monitor.h" - -#if defined (ACE_HAS_KSTAT) - -#include "ace/Log_Category.h" -#include "ace/OS_NS_stdio.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace ACE -{ - namespace Monitor_Control - { - Solaris_Network_Interface_Monitor::Solaris_Network_Interface_Monitor ( - const ACE_TCHAR *lookup_str) - : value_ (0UL), - start_ (0UL), - lookup_str_ (lookup_str) - { - this->init (); - } - - void - Solaris_Network_Interface_Monitor::update_i () - { - this->access_kstats (this->value_); - this->value_ -= this->start_; - } - - void - Solaris_Network_Interface_Monitor::clear_impl () - { - this->init (); - } - - void - Solaris_Network_Interface_Monitor::init () - { - unsigned long i; - - for (i = 0UL; i < MAX_LO_INTERFACES; ++i) - { - this->value_array_lo_[i] = 0UL; - } - - for (i = 0UL; i < MAX_HME_INTERFACES; ++i) - { - this->value_array_hme_[i] = 0UL; - } - - this->access_kstats (this->start_); - } - - void - Solaris_Network_Interface_Monitor::access_kstats ( - ACE_UINT64 &which_member) - { - 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; - int status = 0; - - while (true) - { - /// We have to sum the network interfaces manually. - for (this->kstat_ = this->kstats_->kc_chain; - this->kstat_ != 0; - this->kstat_ = this->kstat_->ks_next) - { - if (ACE_OS::strcmp (this->kstat_->ks_class, "net") != 0) - { - continue; - } - - unsigned long ks_instance = this->kstat_->ks_instance; - - if (ACE_OS::strcmp (this->kstat_->ks_module, "lo") == 0) - { - /// Interfaces 'lo' have only packet counters. - if (this->lookup_str_ == ACE_TEXT ("obytes") - || this->lookup_str_ == ACE_TEXT ("rbytes")) - { - continue; - } - - status = this->check_ks_module (ks_instance, - MAX_LO_INTERFACES, - "MAX_LO_INTERFACES", - this->value_array_lo_, - which_member); - - if (status == -1) - { - /// Unrecoverable error, diagnostic already output. - (void) kstat_close (this->kstats_); - return; - } - else if (status == 1) - { - /// The kstat_id changed underneath us, start over. - break; - } - } - else if (ACE_OS::strcmp (this->kstat_->ks_module, "hme") == 0 - || ACE_OS::strcmp (this->kstat_->ks_module, "bge") == 0) - { - status = this->check_ks_module (ks_instance, - MAX_HME_INTERFACES, - "MAX_HME_INTERFACES", - this->value_array_hme_, - which_member); - - if (status == -1) - { - /// Unrecoverable error, diagnostic already output. - (void) kstat_close (this->kstats_); - return; - } - else if (status == 1) - { - /// The kstat_id changed underneath us, start over. - break; - } - } - } - - if (this->kstat_) - { - this->kstat_id_ = kstat_chain_update (this->kstats_); - - if (! this->kstat_id_ > 0) - { - ACELIB_ERROR ((LM_ERROR, "kstat is is not > 0.\n")); - break; - } - } - else - { - break; - } - } - - status = kstat_close (this->kstats_); - - if (status != 0) - { - ACELIB_ERROR ((LM_ERROR, - ACE_TEXT ("closing kstats file failed\n"))); - } - } - - int - Solaris_Network_Interface_Monitor::check_ks_module ( - const unsigned long ks_instance, - const unsigned long which_max, - const char *max_str, - ACE_UINT64 *value_array, - ACE_UINT64 &which_member) - { - if (! (ks_instance < which_max)) - { - ACELIB_ERROR_RETURN ((LM_ERROR, - "%s exceeded.\n", - max_str), - -1); - } - - /// 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_) - { - /// This return value restarts the walk as described above. - return 1; - } - - kstat_named_t *value = - (kstat_named_t *) kstat_data_lookup ( - this->kstat_, - ACE_TEXT_ALWAYS_CHAR (this->lookup_str_.rep ())); - - if (value == 0) - { - /// Just return and let the calling FOR loop advance. - return 0; - } - - if (value->data_type != KSTAT_DATA_UINT32) - { - ACELIB_ERROR_RETURN ((LM_ERROR, - "Wrong data type.\n"), - -1); - } - - /// Guard against overflow. - value_array[ks_instance] += - value->value.ui32 - - static_cast<ACE_UINT32> (value_array[ks_instance]); - - which_member += value_array[ks_instance]; - - return 0; - } - } -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* defined (ACE_HAS_KSTAT) */ diff --git a/ACE/ace/Monitor_Control/Solaris_Network_Interface_Monitor.h b/ACE/ace/Monitor_Control/Solaris_Network_Interface_Monitor.h deleted file mode 100644 index 15dbc9c50e1..00000000000 --- a/ACE/ace/Monitor_Control/Solaris_Network_Interface_Monitor.h +++ /dev/null @@ -1,89 +0,0 @@ -// -*- C++ -*- - -//============================================================================= -/** - * @file Solaris_Network_Interface_Monitor.h - * - * @author Jeff Parsons <j.parsons@vanderbilt.edu> - */ -//============================================================================= - -#ifndef SOLARIS_NETWORK_INTERFACE_MONITOR_H -#define SOLARIS_NETWORK_INTERFACE_MONITOR_H - -#include /**/ "ace/pre.h" - -#include "ace/SString.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Monitor_Control/Monitor_Control_export.h" - -#if defined (ACE_HAS_KSTAT) - -#include "ace/os_include/os_kstat.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace ACE -{ - namespace Monitor_Control - { - /** - * @class Solaris_Network_Interface_Monitor - * - * @brief Mixin class for network interface monitors compiled on - * Solaris machines. - */ - class MONITOR_CONTROL_Export Solaris_Network_Interface_Monitor - { - protected: - /// The kstat interface can access a wealth of - /// network information about the system. To get the specific - /// value we want to monitor, we just vary the lookup string. - Solaris_Network_Interface_Monitor (const ACE_TCHAR *lookup_str); - - /// Platform-specific implementation. - void update_i (); - - /// Platform-specific reset. - void clear_impl (); - - protected: - ACE_UINT64 value_; - - private: - /// Common code. - - void init (); - void access_kstats (ACE_UINT64 &which_member); - int check_ks_module (const unsigned long ks_instance, - const unsigned long which_max, - const char *max_str, - ACE_UINT64 *value_array, - ACE_UINT64 &which_member); - - - private: - static const unsigned long MAX_LO_INTERFACES = 5UL; - static const unsigned long MAX_HME_INTERFACES = 10UL; - ACE_UINT64 value_array_lo_[MAX_LO_INTERFACES]; - ACE_UINT64 value_array_hme_[MAX_HME_INTERFACES]; - ACE_UINT64 start_; - ACE_TString lookup_str_; - kstat_ctl_t *kstats_; - kstat_t *kstat_; - kid_t kstat_id_; - }; - } -} - -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /* defined (ACE_HAS_KSTAT) */ - -#include /**/ "ace/post.h" - -#endif // SOLARIS_NETWORK_INTERFACE_MONITOR_H |