XRootD
XrdMonitor Class Reference

#include <XrdMonitor.hh>

+ Collaboration diagram for XrdMonitor:

Public Types

enum  Mopts {
  F_JSON = 0x10000000 ,
  X_PLUG = 0x00000001 ,
  X_ADON = 0x00000002
}
 

Public Member Functions

 XrdMonitor ()
 
 ~XrdMonitor ()
 
int Format (char *buff, int bsize, const char *setName, int opts=0)
 
int Format (char *buff, int bsize, int &item, int opts=0)
 
bool Register (XrdMonRoll::rollType setType, const char *setName, XrdMonRoll::Item itemVec[], int itemCnt)
 
bool Registered ()
 

Detailed Description

Definition at line 38 of file XrdMonitor.hh.

Member Enumeration Documentation

◆ Mopts

Enumerator
F_JSON 
X_PLUG 
X_ADON 

Definition at line 44 of file XrdMonitor.hh.

44 {F_JSON = 0x10000000, X_PLUG = 0x00000001, X_ADON = 0x00000002};

Constructor & Destructor Documentation

◆ XrdMonitor()

XrdMonitor::XrdMonitor ( )
inline

Definition at line 55 of file XrdMonitor.hh.

55 {}

◆ ~XrdMonitor()

XrdMonitor::~XrdMonitor ( )
inline

Definition at line 56 of file XrdMonitor.hh.

56 {}

Member Function Documentation

◆ Format() [1/2]

int XrdMonitor::Format ( char *  buff,
int  bsize,
const char *  setName,
int  opts = 0 
)

Definition at line 127 of file XrdMonitor.cc.

128 {
129 // Find the set and format it
130 //
131  RegInfo* regInfo = FindSet(setName, opts);
132  if (!regInfo) return 0;
133  if (opts & F_JSON) bsize = FormJSON(*regInfo, buff, bsize);
134  else bsize = FormXML (*regInfo, buff, bsize);
135  return bsize;
136 }
struct myOpts opts

References F_JSON, and opts.

◆ Format() [2/2]

int XrdMonitor::Format ( char *  buff,
int  bsize,
int &  item,
int  opts = 0 
)

Definition at line 104 of file XrdMonitor.cc.

105 {
106 // Make sure we are in the range of things to format
107 //
108  if (item < 0 || item >= (int)regVec.size()) return 0;
109 
110 // Skip over types that are not wanted
111 //
112  while((regVec[item]->setType & opts) == 0)
113  {item++;
114  if (item >= (int)regVec.size()) return 0;
115  }
116 
117 // Format the item
118 //
119  if (opts & F_JSON) bsize = FormJSON(*regVec[item], buff, bsize);
120  else bsize = FormXML (*regVec[item], buff, bsize);
121  item++;
122  return bsize;
123 }

References F_JSON, and opts.

Referenced by XrdStats::Report().

+ Here is the caller graph for this function:

◆ Register()

bool XrdMonitor::Register ( XrdMonRoll::rollType  setType,
const char *  setName,
XrdMonRoll::Item  itemVec[],
int  itemCnt 
)

Definition at line 308 of file XrdMonitor.cc.

310 {
311  const char* tName = "Plugin";
312  char buff[512];
313 
314 // Determine type of set
315 //
316  sType stype;
317  switch(setType)
318  {case XrdMonRoll::AddOn:
319  case XrdMonRoll::Misc: stype = isAdon; // Deprecated
320  tName = "AddOn";
321  break;
322  case XrdMonRoll::Plugin:
323  case XrdMonRoll::Protocol: stype = isPlug; // Deprecated
324  break;
325  default: stype = isPlug;
326  break;
327  }
328 
329 // Reject invalid sets
330 //
331  if (itemCnt < 1 || itemVec == 0)
332  return RegFail(tName, setName, "invaled parameters");
333 
334 // Make sure this map has not been previously defined
335 //
336  if (FindSet(setName,-1))
337  return RegFail(tName, setName, "set name already registered");
338 
339 
340 // Allocate a new registry
341 //
342  RegInfo* regInfo = new RegInfo(setName, tName, stype);
343  regInfo->iCount = itemCnt;
344  regInfo->iVec = itemVec;
345 
346 // Before registering this specification we need to validate it
347 //
348  if (!Validate(*regInfo))
349  {delete regInfo;
350  return RegFail(tName, setName, "invalid description");
351  }
352 
353 // Complete the registry
354 //
355  regInfo->eTmplt = strdup(buff);
356  snprintf(buff, sizeof(buff), "\"stats_%s\":{", setName);
357  regInfo->Json_hdr = strdup(buff);
358  snprintf(buff, sizeof(buff), "<stats id=\"%s\">", setName);
359  regInfo->Xml_hdr = strdup(buff);
360 
361 // Add registry to our list of registries
362 //
363  regVec.push_back(regInfo);
364 
365 // Display information
366 //
367  snprintf(buff, sizeof(buff), "%s set %s registered with %d items(s)",
368  tName, setName,itemCnt);
369  Log.Say("Config monitor: ", buff);
370  return true;
371 }
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
Definition: XrdSysError.cc:162
XrdSysError Log
Definition: XrdConfig.cc:113

References XrdMonRoll::AddOn, XrdGlobal::Log, XrdMonRoll::Misc, XrdMonRoll::Plugin, XrdMonRoll::Protocol, and XrdSysError::Say().

Referenced by XrdMonRoll::Register().

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

◆ Registered()

bool XrdMonitor::Registered ( )
inline

Definition at line 53 of file XrdMonitor.hh.

53 {return !regVec.empty();}

Referenced by XrdStats::Report().

+ Here is the caller graph for this function:

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