Loading...
Searching...
No Matches
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 | Export (XrdOucEnv &env)
void | Init (char **Dest, int iVal=600, int xOpts=0, int jOpts=0)
void | Report ()
virtual void | Stats (XrdStats::CallBack *InfoBack, int xOpts, int jOpts=0)

## Detailed Description

Definition at line 62 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 83 of file XrdStats.cc.

{
const char *head =
"<statistics tod=\"%%ld\" ver=\"" XrdVERSION "\" src=\"%s:%d\" "
"tos=\"%ld\" pgm=\"%s\" ins=\"%s\" pid=\"%d\" "
"site=\"%s\">";
Hend = "</statistics>";
Htln = strlen(Hend);
const char *jead =
"{\"statistics\":{\"tod\":%%ld,\"ver\":\"" XrdVERSION "\",\"src\":\"%s:%d\","
"\"tos\":%ld,\"pgm\":\"%s\",\"ins\":\"%s\",\"pid\":%d,"
"\"site\":\"%s\",";
Jend = "}}";
Jtln = 2;
char myBuff[1024];
XrdLog = eP;
XrdSched = sP;
BuffPool = bP;
sprintf(myBuff, head, hname, port, tBoot, pname, iname,
static_cast<int>(getpid()), (site ? site : ""));
Head = strdup(myBuff);
sprintf(myBuff, jead, hname, port, tBoot, pname, iname,
static_cast<int>(getpid()), (site ? site : ""));
Jead = strdup(myBuff);
// Allocate a shared buffer. Buffer use is serialized via the statsMutex.
//
blen = 64*1024; // 64K which is the largest allowed UDP packet
if (posix_memalign((void **)&buff, getpagesize(), blen)) buff = 0;
myHost = hname;
myName = iname;
myPort = port;
theMon = new XrdMonitor;
}

## ~XrdStats()

virtual XrdStats::~XrdStats | ( |  | ) |

inline virtual

Definition at line 92 of file XrdStats.hh.

{if (buff) free(buff);}

## Member Function Documentation

## Export()

void XrdStats::Export | ( | XrdOucEnv & | env | ) |

Definition at line 131 of file XrdStats.cc.

{
XrdMonRoll* monRoll = new XrdMonRoll(*theMon);
theEnv.PutPtr("XrdMonRoll*", monRoll);
}
XrdOucEnv::PutPtr
void PutPtr(const char *varname, void *value)
Definition XrdOucEnv.cc:298
XrdCms::theEnv
XrdOucEnv theEnv
Definition XrdCmsConfig.cc:102

References XrdOucEnv::PutPtr().

Here is the call graph for this function:

## Init()

void XrdStats::Init | ( | char ** | Dest,
|  | int | iVal = 600,
|  | int | xOpts = 0,
|  | int | jOpts = 0 )

Definition at line 141 of file XrdStats.cc.

{
// Establish up to two destinations
//
if (Dest[0]) netDest[0] = new XrdNetMsg(XrdLog, Dest[0]);
if (Dest[1]) netDest[1] = new XrdNetMsg(XrdLog, Dest[1]);
// Establish auto reporting options
//
if (!(jOpts & XRD_STATS_ALLJ) && !(xOpts & XRD_STATS_ALLX))
xOpts |= XRD_STATS_ALLX; // ALLX includes ALLJ
jsonOpts = (jOpts & XRD_STATS_ALLJ) | XRD_STATS_JSON; xmlOpts = xOpts;
autoSync = xOpts & XRD_STATS_SYNCA;
// Get and schedule a new job to report
//
if (netDest[0]) new XrdStatsJob(XrdSched, this, iVal);
return;
}
XRD_STATS_JSON
#define XRD_STATS_JSON
Definition XrdStats.hh:52
XRD_STATS_SYNCA
#define XRD_STATS_SYNCA
Definition XrdStats.hh:50
XRD_STATS_ALLX
#define XRD_STATS_ALLX
Definition XrdStats.hh:39
XRD_STATS_ALLJ
#define XRD_STATS_ALLJ
Definition XrdStats.hh:38

References XRD_STATS_ALLJ, XRD_STATS_ALLX, XRD_STATS_JSON, and XRD_STATS_SYNCA.

## Report()

void XrdStats::Report | ( |  | ) |

Definition at line 166 of file XrdStats.cc.

{
char udpBuff[64*1024];
const char *Data;
int theOpts, Dlen;
// This is an entry for reporting purposes, establish the sync flag
//
if (!autoSync || XrdSched->Active() <= 30) theOpts = xmlOpts;
else theOpts = xmlOpts & ~XRD_STATS_SYNC;
// Now get the statistics in xml format. Note that there is only one buufer
// so we lock this code path to protect it.
//
statsMutex.Lock();
if ((Data = GenStats(Dlen, theOpts)))
{netDest[0]->Send(Data, Dlen);
if (netDest[1]) netDest[1]->Send(Data, Dlen);
}
statsMutex.UnLock();
// Check if we have additional data registered via addons and plugins that
// we need in JSON format. These are sent as separate udp packets.
//
theOpts = XrdMonitor::F_JSON;
if (jsonOpts & XRD_STATS_ADON) theOpts |= XrdMonitor::X_ADON;
if (jsonOpts & XRD_STATS_PLUG) theOpts |= XrdMonitor::X_PLUG;
if (!(theOpts & ~XrdMonitor::F_JSON) || !theMon->Registered()) return;
// Format the header and setup for sending packets
//
int hL = sprintf(udpBuff, Jead, time(0));
int bL = sizeof(udpBuff) - hL - Jtln - 8;
char* bP = udpBuff + hL;
// Get each item and send it off
//
struct iovec ioV[3];
ioV[0].iov_base = udpBuff;
ioV[0].iov_len = hL;
ioV[1].iov_base = bP;
ioV[2].iov_base = (void*)Jend;
ioV[2].iov_len = Jtln;
int uL, sItem = 0;
while((uL = theMon->Format(bP, bL, sItem, theOpts)))
{ioV[1].iov_len = uL;
netDest[0]->Send(ioV, 3);
if (netDest[1]) netDest[1]->Send(ioV, 3);
}
}
XRD_STATS_ADON
#define XRD_STATS_ADON
Definition XrdStats.hh:37
XRD_STATS_PLUG
#define XRD_STATS_PLUG
Definition XrdStats.hh:43
XrdMonitor::X_PLUG
@ X_PLUG
Definition XrdMonitor.hh:45
XrdMonitor::F_JSON
@ F_JSON
Definition XrdMonitor.hh:45
XrdMonitor::X_ADON
@ X_ADON
Definition XrdMonitor.hh:45

References XrdMonitor::F_JSON, XrdMonitor::X_ADON, XrdMonitor::X_PLUG, XRD_STATS_ADON, XRD_STATS_PLUG, and XRD_STATS_SYNC.

## Stats()

void XrdStats::Stats | ( | XrdStats::CallBack * | InfoBack,
|  | int | xOpts,
|  | int | jOpts = 0 )

virtual

Definition at line 221 of file XrdStats.cc.

{
const char *info;
int sz, opts;
// Note that currently we do not support json for client requests, so we
// ignore the jOpts as they should never be set.
//
opts = xOpts;
// Lock the buffer,
//
statsMutex.Lock();
// Obtain the stats, if we have some, do the callback. We currently do not
// support return of JSON format as some statistics can't provide it.
//
if ((info = GenStats(sz, opts))) cbP->Info(info, sz);
// Unlock the buffer
//
statsMutex.UnLock();
}
opts
struct myOpts opts

References XrdStats::CallBack::Info(), and opts.

Here is the call graph for this function:

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

- XrdStats.hh
- XrdStats.cc