XRootD
XrdStats Class Reference

#include <XrdStats.hh>

+ Collaboration diagram for XrdStats:

Classes

class  CallBack
 

Public Member Functions

 XrdStats (XrdSysError *eP, XrdScheduler *sP, XrdBuffManager *bP, const char *hn, int port, const char *in, const char *pn, const char *sn)
 
virtual ~XrdStats ()
 
void Report (char **Dest=0, int iVal=600, int Opts=0)
 
virtual void Stats (CallBack *InfoBack, int opts)
 

Detailed Description

Definition at line 51 of file XrdStats.hh.

Constructor & Destructor Documentation

◆ XrdStats()

XrdStats::XrdStats ( XrdSysError eP,
XrdScheduler sP,
XrdBuffManager bP,
const char *  hn,
int  port,
const char *  in,
const char *  pn,
const char *  sn 
)

Definition at line 80 of file XrdStats.cc.

83 {
84  static const char *head =
85  "<statistics tod=\"%%ld\" ver=\"" XrdVERSION "\" src=\"%s:%d\" "
86  "tos=\"%ld\" pgm=\"%s\" ins=\"%s\" pid=\"%d\" "
87  "site=\"%s\">";
88  char myBuff[1024];
89 
90  XrdLog = eP;
91  XrdSched = sP;
92  BuffPool = bP;
93 
94  Hlen = sprintf(myBuff, head, hname, port, tBoot, pname, iname,
95  static_cast<int>(getpid()), (site ? site : ""));
96  Head = strdup(myBuff);
97  buff = 0;
98  blen = 0;
99  myHost = hname;
100  myName = iname;
101  myPort = port;
102 }

◆ ~XrdStats()

virtual XrdStats::~XrdStats ( )
inlinevirtual

Definition at line 70 of file XrdStats.hh.

70 {if (buff) free(buff);}

Member Function Documentation

◆ Report()

void XrdStats::Report ( char **  Dest = 0,
int  iVal = 600,
int  Opts = 0 
)

Definition at line 108 of file XrdStats.cc.

109 {
110  static XrdNetMsg *netDest[2] = {0,0};
111  static int autoSync, repOpts = Opts;
112  const char *Data;
113  int theOpts, Dlen;
114 
115 // If we have dest then this is for initialization
116 //
117  if (Dest)
118  // Establish up to two destinations
119  //
120  {if (Dest[0]) netDest[0] = new XrdNetMsg(XrdLog, Dest[0]);
121  if (Dest[1]) netDest[1] = new XrdNetMsg(XrdLog, Dest[1]);
122  if (!(repOpts & XRD_STATS_ALL)) repOpts |= XRD_STATS_ALL;
123  autoSync = repOpts & XRD_STATS_SYNCA;
124 
125  // Get and schedule a new job to report
126  //
127  if (netDest[0]) new XrdStatsJob(XrdSched, this, iVal);
128  return;
129  }
130 
131 // This is a re-entry for reporting purposes, establish the sync flag
132 //
133  if (!autoSync || XrdSched->Active() <= 30) theOpts = repOpts;
134  else theOpts = repOpts & ~XRD_STATS_SYNC;
135 
136 // Now get the statistics
137 //
138  statsMutex.Lock();
139  if ((Data = GenStats(Dlen, theOpts)))
140  {netDest[0]->Send(Data, Dlen);
141  if (netDest[1]) netDest[1]->Send(Data, Dlen);
142  }
143  statsMutex.UnLock();
144 }
#define XRD_STATS_SYNC
Definition: XrdStats.hh:45
#define XRD_STATS_SYNCA
Definition: XrdStats.hh:46
#define XRD_STATS_ALL
Definition: XrdStats.hh:36
int Send(const char *buff, int blen=0, const char *dest=0, int tmo=-1)
Definition: XrdNetMsg.cc:70
int Opts
Definition: XrdMpxStats.cc:58

References XrdScheduler::Active(), XrdSysMutex::Lock(), XrdMpx::Opts, XrdNetMsg::Send(), XrdSysMutex::UnLock(), XRD_STATS_ALL, XRD_STATS_SYNC, and XRD_STATS_SYNCA.

Referenced by XrdStatsJob::DoIt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Stats()

void XrdStats::Stats ( XrdStats::CallBack cbP,
int  opts 
)
virtual

Definition at line 150 of file XrdStats.cc.

151 {
152  const char *info;
153  int sz;
154 
155 // Lock the buffer,
156 //
157  statsMutex.Lock();
158 
159 // Obtain the stats, if we have some, do the callback
160 //
161  if ((info = GenStats(sz, opts))) cbP->Info(info, sz);
162 
163 // Unlock the buffer
164 //
165  statsMutex.UnLock();
166 }
struct myOpts opts
virtual void Info(const char *data, int dlen)=0

References XrdStats::CallBack::Info(), XrdSysMutex::Lock(), opts, and XrdSysMutex::UnLock().

Referenced by XrdXrootdStats::Stats().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: