xrootd
|
00001 #ifndef __CMS_METER__H 00002 #define __CMS_METER__H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s M e t e r . h h */ 00006 /* */ 00007 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id$ 00014 00015 #include "XrdSys/XrdSysError.hh" 00016 #include "XrdSys/XrdSysPthread.hh" 00017 #include "XrdOuc/XrdOucStream.hh" 00018 00019 class XrdCmsMeter 00020 { 00021 public: 00022 00023 int calcLoad(int pcpu, int pio, int pload, int pmem, int ppag); 00024 00025 int calcLoad(int xload,int pdsk); 00026 00027 int FreeSpace(int &tutil); 00028 00029 void Init(); 00030 00031 int isOn() {return Running;} 00032 00033 int Monitor(char *pgm, int itv); 00034 00035 void Record(int pcpu, int pnet, int pxeq, 00036 int pmem, int ppag, int pdsk); 00037 00038 int Report(int &pcpu, int &pnet, int &pxeq, 00039 int &pmem, int &ppag, int &pdsk); 00040 00041 void *Run(); 00042 00043 void *RunFS(); 00044 00045 int numFS() {return fs_nums;} 00046 00047 unsigned int TotalSpace(unsigned int &minfree); 00048 00049 enum vType {manFS = 1, peerFS = 2}; 00050 00051 void setVirtual(vType vVal) {Virtual = vVal;} 00052 00053 void setVirtUpdt() {cfsMutex.Lock(); VirtUpdt = 1; cfsMutex.UnLock();} 00054 00055 XrdCmsMeter(); 00056 ~XrdCmsMeter(); 00057 00058 private: 00059 void calcSpace(); 00060 char Scale(long long inval, long &outval); 00061 void SpaceMsg(int why); 00062 void UpdtSpace(); 00063 00064 XrdOucStream myMeter; 00065 XrdSysMutex cfsMutex; 00066 XrdSysMutex repMutex; 00067 long long MinFree; // Calculated only once 00068 long long HWMFree; // Calculated only once 00069 long long dsk_lpn; // Calculated only once 00070 long long dsk_tot; // Calculated only once 00071 long long dsk_free; 00072 long long dsk_maxf; 00073 int dsk_util; 00074 int dsk_calc; 00075 int fs_nums; // Calculated only once 00076 int lastFree; 00077 int lastUtil; 00078 int noSpace; 00079 int Running; 00080 long MinShow; // Calculated only once 00081 long HWMShow; // Calculated only once 00082 char MinStype; // Calculated only once 00083 char HWMStype; // Calculated only once 00084 char Virtual; // This is a virtual filesystem 00085 char VirtUpdt; // Data changed for the virtul FS 00086 00087 time_t rep_tod; 00088 char *monpgm; 00089 int monint; 00090 pthread_t montid; 00091 00092 unsigned int xeq_load; 00093 unsigned int cpu_load; 00094 unsigned int mem_load; 00095 unsigned int pag_load; 00096 unsigned int net_load; 00097 }; 00098 00099 namespace XrdCms 00100 { 00101 extern XrdCmsMeter Meter; 00102 } 00103 #endif