00001 #ifndef __XRD_STATS_H__ 00002 #define __XRD_STATS_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S t a t s . h h */ 00006 /* */ 00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved. See XrdInfo.cc for complete License Terms */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC03-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id: XrdStats.hh 29874 2009-08-21 16:56:04Z ganis $ 00014 00015 #include <stdlib.h> 00016 00017 #include "XrdSys/XrdSysPthread.hh" 00018 00019 #define XRD_STATS_ALL 0x000000FF 00020 #define XRD_STATS_INFO 0x00000001 00021 #define XRD_STATS_BUFF 0x00000002 00022 #define XRD_STATS_LINK 0x00000004 00023 #define XRD_STATS_POLL 0x00000008 00024 #define XRD_STATS_PROC 0x00000010 00025 #define XRD_STATS_PROT 0x00000020 00026 #define XRD_STATS_SCHD 0x00000040 00027 #define XRD_STATS_SGEN 0x00000080 00028 #define XRD_STATS_SYNC 0x40000000 00029 #define XRD_STATS_SYNCA 0x20000000 00030 00031 class XrdStats 00032 { 00033 public: 00034 00035 void Report(char **Dest=0, int iVal=600, int Opts=0); 00036 00037 void Lock() {statsMutex.Lock();} // Call before doing Stats() 00038 00039 const char *Stats(int opts); 00040 00041 void UnLock() {statsMutex.UnLock();} // Call after inspecting buffer 00042 00043 XrdStats(const char *hn, int port, const char *in, const char *pn); 00044 00045 ~XrdStats() {if (buff) free(buff);} 00046 00047 private: 00048 00049 int InfoStats(char *buff, int blen, int dosync=0); 00050 int ProcStats(char *buff, int blen, int dosync=0); 00051 00052 static long tBoot; // Time at boot time 00053 00054 XrdSysMutex statsMutex; 00055 00056 char *buff; // Used by all callers 00057 int blen; 00058 int Hlen; 00059 char *Head; 00060 const char *myHost; 00061 const char *myName; 00062 int myPort; 00063 }; 00064 #endif