xrootd
XrdCmsMeter.hh
Go to the documentation of this file.
1 #ifndef __CMS_METER__H
2 #define __CMS_METER__H
3 /******************************************************************************/
4 /* */
5 /* X r d C m s M e t e r . h h */
6 /* */
7 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 // $Id$
14 
15 #include "XrdSys/XrdSysError.hh"
16 #include "XrdSys/XrdSysPthread.hh"
17 #include "XrdOuc/XrdOucStream.hh"
18 
20 {
21 public:
22 
23 int calcLoad(int pcpu, int pio, int pload, int pmem, int ppag);
24 
25 int calcLoad(int xload,int pdsk);
26 
27 int FreeSpace(int &tutil);
28 
29 void Init();
30 
31 int isOn() {return Running;}
32 
33 int Monitor(char *pgm, int itv);
34 
35 void Record(int pcpu, int pnet, int pxeq,
36  int pmem, int ppag, int pdsk);
37 
38 int Report(int &pcpu, int &pnet, int &pxeq,
39  int &pmem, int &ppag, int &pdsk);
40 
41 void *Run();
42 
43 void *RunFS();
44 
45 int numFS() {return fs_nums;}
46 
47 unsigned int TotalSpace(unsigned int &minfree);
48 
49 enum vType {manFS = 1, peerFS = 2};
50 
51 void setVirtual(vType vVal) {Virtual = vVal;}
52 
54 
55  XrdCmsMeter();
56  ~XrdCmsMeter();
57 
58 private:
59  void calcSpace();
60  char Scale(long long inval, long &outval);
61  void SpaceMsg(int why);
62  void UpdtSpace();
63 
67 long long MinFree; // Calculated only once
68 long long HWMFree; // Calculated only once
69 long long dsk_lpn; // Calculated only once
70 long long dsk_tot; // Calculated only once
71 long long dsk_free;
72 long long dsk_maxf;
75 int fs_nums; // Calculated only once
78 int noSpace;
79 int Running;
80 long MinShow; // Calculated only once
81 long HWMShow; // Calculated only once
82 char MinStype; // Calculated only once
83 char HWMStype; // Calculated only once
84 char Virtual; // This is a virtual filesystem
85 char VirtUpdt; // Data changed for the virtul FS
86 
87 time_t rep_tod;
88 char *monpgm;
89 int monint;
90 pthread_t montid;
91 
92 unsigned int xeq_load;
93 unsigned int cpu_load;
94 unsigned int mem_load;
95 unsigned int pag_load;
96 unsigned int net_load;
97 };
98 
99 namespace XrdCms
100 {
101 extern XrdCmsMeter Meter;
102 }
103 #endif