Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef CPU_LOAD_MONITOR_H
00014 #define CPU_LOAD_MONITOR_H
00015
00016 #include "ace/pre.h"
00017
00018 #include "ace/Monitor_Base.h"
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 #pragma once
00022 #endif
00023
00024 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
00025
00026 #if defined (ACE_HAS_PDH_H) && !defined (ACE_LACKS_PDH_H)
00027 #include "ace/Monitor_Control/Windows_Monitor.h"
00028 #elif defined (ACE_HAS_KSTAT)
00029 #include "ace/os_include/os_kstat.h"
00030 #endif
00031
00032 #include "ace/Monitor_Control/Monitor_Control_export.h"
00033
00034 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00035
00036 namespace ACE
00037 {
00038 namespace Monitor_Control
00039 {
00040
00041
00042
00043
00044
00045 class MONITOR_CONTROL_Export CPU_Load_Monitor
00046 : public Monitor_Base
00047 #if defined (ACE_HAS_WIN32_PDH)
00048 , public Windows_Monitor
00049 #endif
00050 {
00051 public:
00052 CPU_Load_Monitor (const char* name);
00053
00054
00055 virtual void update (void);
00056
00057
00058 static const char* default_name (void);
00059
00060 private:
00061
00062 virtual void clear_i (void);
00063
00064
00065 void init (void);
00066
00067 private:
00068 #if defined (linux)
00069 void access_proc_stat (unsigned long *which_idle);
00070 #endif
00071
00072 #if defined (ACE_HAS_KSTAT)
00073 void access_kstats (unsigned long *which_idle);
00074 #endif
00075
00076 private:
00077 static const char* default_name_;
00078
00079
00080 #if defined (linux) || defined (ACE_HAS_KSTAT)
00081 unsigned long user_;
00082 unsigned long wait_;
00083 unsigned long kernel_;
00084 unsigned long idle_;
00085 unsigned long prev_idle_;
00086 double prev_total_;
00087 #endif
00088 #if defined (linux)
00089 FILE *file_ptr_;
00090 char buf_[1024];
00091 #elif defined (ACE_HAS_KSTAT)
00092 kstat_ctl_t *kstats_;
00093 kstat_t *kstat_;
00094 kid_t kstat_id_;
00095 #endif
00096 };
00097 }
00098 }
00099
00100 ACE_END_VERSIONED_NAMESPACE_DECL
00101
00102 #endif
00103
00104 #include "ace/post.h"
00105
00106 #endif // CPU_LOAD_MONITOR_H