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.30 2011/11/10 10:56:37 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 
12 #ifdef __APPLE__
13 #include <sys/param.h>
14 #include <sys/mount.h>
15 #else
16 #include <sys/statfs.h>
17 #endif
18 
19 #include <boost/thread/mutex.hpp>
20 #include <boost/shared_ptr.hpp>
21 
22 #include "xdata/Integer32.h"
23 #include "xdata/String.h"
24 #include "xdata/UnsignedInteger32.h"
25 #include "xdata/Vector.h"
26 
30 
31 
32 namespace stor {
33 
34  class testResourceMonitorCollection;
35 
45  {
46  public:
47 
48  // Allow unit test to access the private methods
50 
52  {
53  double absDiskUsage; // absolute disk usage in GB
54  double relDiskUsage; // percentage of disk space occupied
55  double diskSize; // absolute size of disk in GB
56  std::string pathName; // path of the disk
57  AlarmHandler::ALARM_LEVEL alarmState; // alarm level of the disk usage
58  };
59  typedef boost::shared_ptr<DiskUsageStats> DiskUsageStatsPtr;
60  typedef std::vector<DiskUsageStatsPtr> DiskUsageStatsPtrList;
61 
62  struct Stats
63  {
65 
68  int sataBeastStatus; // status code of SATA beast
69  };
70 
71 
76  (
77  const utils::Duration_t& updateInterval,
79  );
80 
84  void configureDisks(DiskWritingParams const&);
85 
90 
94  void configureAlarms(AlarmParams const&);
95 
99  void getStats(Stats&) const;
100 
101 
102  private:
103 
104  struct DiskUsage
105  {
106  const std::string pathName_;
109  double diskSize_;
112  #if __APPLE__
113  struct statfs statfs_;
114  #else
115  struct statfs64 statfs_;
116  #endif
117  int retVal_;
118  DiskUsage(const std::string& pathName);
119  std::string toString();
120  };
121  typedef boost::shared_ptr<DiskUsage> DiskUsagePtr;
122  typedef std::vector<DiskUsagePtr> DiskUsagePtrList;
125 
128 
129  //Prevent copying of the ResourceMonitorCollection
132 
133  virtual void do_calculateStatistics();
134  virtual void do_reset();
136  virtual void do_updateInfoSpaceItems();
137 
138  void addDisk(const std::string&);
139  void addOtherDisks();
140  bool isImportantDisk(const std::string&);
144 
145  void getDiskStats(Stats&) const;
146  void calcDiskUsage();
148  void doStatFs(DiskUsagePtr);
149 
154  int getProcessCount(const std::string& processName, const int& uid=-1);
155 
156  typedef std::set<std::string> SATABeasts;
157  void checkSataBeasts();
158  bool getSataBeasts(SATABeasts& sataBeasts);
159  void checkSataBeast(const std::string& sataBeast);
160  bool checkSataDisks(const std::string& sataBeast, const std::string& hostSuffix);
161  void updateSataBeastStatus(const std::string& sataBeast, const std::string& content);
162 
166 
169  unsigned int nLogicalDisks_;
171 
172  xdata::UnsignedInteger32 copyWorkers_; // number of running copyWorkers
173  xdata::UnsignedInteger32 injectWorkers_; // number of running injectWorkers
174  xdata::Integer32 sataBeastStatus_; // status code of SATA beast
175  xdata::UnsignedInteger32 numberOfDisks_; // number of disks used for writing
176  xdata::Vector<xdata::String> diskPaths_; // list of disk paths
177  xdata::Vector<xdata::UnsignedInteger32> totalDiskSpace_; // total disk space
178  xdata::Vector<xdata::UnsignedInteger32> usedDiskSpace_; // used disk space
179 
180  };
181 
182 } // namespace stor
183 
184 #endif // EventFilter_StorageManager_ResourceMonitorCollection_h
185 
186 
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:116
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 configureResources(ResourceMonitorParams const &)
int getProcessCount(const std::string &processName, const int &uid=-1)