CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ResourceMonitorCollection.h
Go to the documentation of this file.
1 // $Id: ResourceMonitorCollection.h,v 1.27.4.1 2011/03/07 11:33:04 mommsen Exp $
3 
4 #ifndef EventFilter_StorageManager_ResourceMonitorCollection_h
5 #define EventFilter_StorageManager_ResourceMonitorCollection_h
6 
7 #include <set>
8 #include <vector>
9 #include <string>
10 #include <errno.h>
11 #ifdef __APPLE__
12 typedef int error_t;
13 #endif
14 
15 #include <boost/thread/mutex.hpp>
16 #include <boost/shared_ptr.hpp>
17 
18 #include "xdata/Integer32.h"
19 #include "xdata/String.h"
20 #include "xdata/UnsignedInteger32.h"
21 #include "xdata/Vector.h"
22 
26 
27 
28 namespace stor {
29 
30  class testResourceMonitorCollection;
31 
41  {
42  public:
43 
44  // Allow unit test to access the private methods
46 
48  {
49  double absDiskUsage; // absolute disk usage in GB
50  double relDiskUsage; // percentage of disk space occupied
51  double diskSize; // absolute size of disk in GB
52  std::string pathName; // path of the disk
53  AlarmHandler::ALARM_LEVEL alarmState; // alarm level of the disk usage
54  };
55  typedef boost::shared_ptr<DiskUsageStats> DiskUsageStatsPtr;
56  typedef std::vector<DiskUsageStatsPtr> DiskUsageStatsPtrList;
57 
58  struct Stats
59  {
61 
64  int sataBeastStatus; // status code of SATA beast
65  };
66 
67 
72  (
73  const utils::Duration_t& updateInterval,
75  );
76 
80  void configureDisks(DiskWritingParams const&);
81 
86 
90  void configureAlarms(AlarmParams const&);
91 
95  void getStats(Stats&) const;
96 
97 
98  private:
99 
100  struct DiskUsage
101  {
102  double absDiskUsage;
103  double relDiskUsage;
104  double diskSize;
105  std::string pathName;
107  std::string toString();
108  };
109  typedef boost::shared_ptr<DiskUsage> DiskUsagePtr;
110  typedef std::vector<DiskUsagePtr> DiskUsagePtrList;
113 
116 
117  //Prevent copying of the ResourceMonitorCollection
120 
121  virtual void do_calculateStatistics();
122  virtual void do_reset();
124  virtual void do_updateInfoSpaceItems();
125 
126  void addDisk(const std::string&);
127  void addOtherDisks();
129  void emitDiskAlarm(DiskUsagePtr, error_t);
132 
133  void getDiskStats(Stats&) const;
134  void calcDiskUsage();
136 
141  int getProcessCount(const std::string& processName, const int& uid=-1);
142 
143  typedef std::set<std::string> SATABeasts;
144  void checkSataBeasts();
145  bool getSataBeasts(SATABeasts& sataBeasts);
146  void checkSataBeast(const std::string& sataBeast);
147  bool checkSataDisks(const std::string& sataBeast, const std::string& hostSuffix);
148  void updateSataBeastStatus(const std::string& sataBeast, const std::string& content);
149 
153 
156  unsigned int nLogicalDisks_;
158 
159  xdata::UnsignedInteger32 copyWorkers_; // number of running copyWorkers
160  xdata::UnsignedInteger32 injectWorkers_; // number of running injectWorkers
161  xdata::Integer32 sataBeastStatus_; // status code of SATA beast
162  xdata::UnsignedInteger32 numberOfDisks_; // number of disks used for writing
163  xdata::Vector<xdata::String> diskPaths_; // list of disk paths
164  xdata::Vector<xdata::UnsignedInteger32> totalDiskSpace_; // total disk space
165  xdata::Vector<xdata::UnsignedInteger32> usedDiskSpace_; // used disk space
166 
167  };
168 
169 } // namespace stor
170 
171 #endif // EventFilter_StorageManager_ResourceMonitorCollection_h
172 
173 
ResourceMonitorCollection(const utils::Duration_t &updateInterval, AlarmHandlerPtr)
static boost::mutex mutex
Definition: LHEProxy.cc:11
std::vector< DiskUsagePtr > DiskUsagePtrList
boost::shared_ptr< DiskUsage > DiskUsagePtr
ResourceMonitorCollection & operator=(ResourceMonitorCollection const &)
boost::posix_time::time_duration Duration_t
Definition: Utils.h:41
xdata::Vector< xdata::UnsignedInteger32 > usedDiskSpace_
void configureDisks(DiskWritingParams const &)
bool checkSataDisks(const std::string &sataBeast, const std::string &hostSuffix)
xdata::Vector< xdata::UnsignedInteger32 > totalDiskSpace_
boost::shared_ptr< AlarmHandler > AlarmHandlerPtr
Definition: AlarmHandler.h:91
virtual void do_appendInfoSpaceItems(InfoSpaceItems &)
std::vector< DiskUsageStatsPtr > DiskUsageStatsPtrList
void checkSataBeast(const std::string &sataBeast)
xdata::Vector< xdata::String > diskPaths_
bool getSataBeasts(SATABeasts &sataBeasts)
boost::shared_ptr< DiskUsageStats > DiskUsageStatsPtr
std::vector< std::pair< std::string, xdata::Serializable * > > InfoSpaceItems
void updateSataBeastStatus(const std::string &sataBeast, const std::string &content)
void emitDiskAlarm(DiskUsagePtr, error_t)
void configureResources(ResourceMonitorParams const &)
int getProcessCount(const std::string &processName, const int &uid=-1)