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 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include "XrdCms/XrdCmsPerfMon.hh"
34 #include "XrdSys/XrdSysError.hh"
35 #include "XrdSys/XrdSysPthread.hh"
36 #include "XrdOuc/XrdOucStream.hh"
37 
38 class XrdCmsMeter : public XrdCmsPerfMon
39 {
40 public:
41 
42 int calcLoad(uint32_t pcpu, uint32_t pio, uint32_t pload,
43  uint32_t pmem, uint32_t ppag);
44 
45 int calcLoad(int xload, uint32_t pdsk);
46 
47 int FreeSpace(int &tutil);
48 
49 void Init();
50 
51 int isOn() {return Running;}
52 
53 int Monitor(char *pgm, int itv);
54 int Monitor(int itv);
55 
56 void PutInfo(XrdCmsPerfMon::PerfInfo &perfInfo, bool alert=false);
57 
58 void Record(int pcpu, int pnet, int pxeq,
59  int pmem, int ppag, int pdsk);
60 
61 int Report(int &pcpu, int &pnet, int &pxeq,
62  int &pmem, int &ppag, int &pdsk);
63 
64 void *Run();
65 
66 void *RunFS();
67 
68 void *RunPM();
69 
70 int numFS() {return fs_nums;}
71 
72 unsigned int TotalSpace(unsigned int &minfree);
73 
74 enum vType {manFS = 1, peerFS = 2};
75 
76 void setVirtual(vType vVal) {Virtual = vVal;}
77 
78 void setVirtUpdt() {cfsMutex.Lock(); VirtUpdt = 1; cfsMutex.UnLock();}
79 
80 bool Update(char *line, bool alert=false);
81 
82  XrdCmsMeter();
83  ~XrdCmsMeter();
84 
85 private:
86  void calcSpace();
87  char Scale(long long inval, long &outval);
88  void SpaceMsg(int why);
89  void UpdtSpace();
90 
91 XrdOucStream myMeter;
92 XrdSysMutex cfsMutex;
93 XrdSysMutex repMutex;
94 long long MinFree; // Calculated only once
95 long long HWMFree; // Calculated only once
96 long long dsk_lpn; // Calculated only once
97 long long dsk_tot; // Calculated only once
98 long long dsk_free;
99 long long dsk_maxf;
100 int dsk_util;
101 int dsk_calc;
102 int fs_nums; // Calculated only once
103 int lastFree;
104 int lastUtil;
105 int noSpace;
106 int Running;
107 long MinShow; // Calculated only once
108 long HWMShow; // Calculated only once
109 char MinStype; // Calculated only once
110 char HWMStype; // Calculated only once
111 char Virtual; // This is a virtual filesystem
112 char VirtUpdt; // Data changed for the virtul FS
113 
114 time_t rep_tod;
115 char *monpgm;
116 XrdCmsPerfMon *monPerf;
117 int monint;
118 pthread_t montid;
119 
120 uint32_t xeq_load;
121 uint32_t cpu_load;
122 uint32_t mem_load;
123 uint32_t pag_load;
124 uint32_t net_load;
125 int myLoad;
126 int prevLoad;
127 };
128 
129 namespace XrdCms
130 {
132 }
133 #endif
void * RunPM()
Definition: XrdCmsMeter.cc:449
bool Update(char *line, bool alert=false)
Definition: XrdCmsMeter.cc:502
int Monitor(char *pgm, int itv)
Definition: XrdCmsMeter.cc:258
void * RunFS()
Definition: XrdCmsMeter.cc:424
void Record(int pcpu, int pnet, int pxeq, int pmem, int ppag, int pdsk)
Definition: XrdCmsMeter.cc:351
int Report(int &pcpu, int &pnet, int &pxeq, int &pmem, int &ppag, int &pdsk)
Definition: XrdCmsMeter.cc:374
unsigned int TotalSpace(unsigned int &minfree)
Definition: XrdCmsMeter.cc:468
void PutInfo(XrdCmsPerfMon::PerfInfo &perfInfo, bool alert=false)
Definition: XrdCmsMeter.cc:324
int FreeSpace(int &tutil)
Definition: XrdCmsMeter.cc:158
int calcLoad(uint32_t pcpu, uint32_t pio, uint32_t pload, uint32_t pmem, uint32_t ppag)
Definition: XrdCmsMeter.cc:130
void setVirtUpdt()
Definition: XrdCmsMeter.hh:78
void setVirtual(vType vVal)
Definition: XrdCmsMeter.hh:76
void * Run()
Definition: XrdCmsMeter.cc:402
XrdCmsMeter Meter
Definition: XrdCmsMeter.hh:131
Structure used for reporting performance metrics.