69 void Exported() {monDest[0] = monDest[1] = 0;}
71 MonParms() : monDest{0,0}, monMode{0,0}, monFlash(0), monFlush(0),
72 monGBval(0), monMBval(0), monRBval(0), monWWval(0),
73 monFbsz(0), monIdent(3600),monRnums(0),
74 monFSint(0), monFSopt(0), monFSion(0) {}
75 ~MonParms() {
if (monDest[0]) free(monDest[0]);
76 if (monDest[1]) free(monDest[1]);
107 bool aOK, gXrd[numgs] = {
false,
false,
false,
true,
false,
true};
112 for (
int i = 0; i < numgs; i++)
114 {
if (MP && gsObj[i].
maxL <= 0) gsObj[i].maxL = MP->monGBval;
116 if (!aOK)
return false;
117 snprintf(vbuff,
sizeof(vbuff),
"%s.gStream*", gsObj[i].
pin);
118 if (!gXrd[i]) myEnv.
PutPtr(vbuff, (
void *)gs);
119 else if (urEnv) urEnv->
PutPtr(vbuff, (
void *)gs);
145 for (i = 0; i < numgs && !gsObj[i].dest; i++);
146 if (i < numgs && !MP) MP =
new MonParms;
147 else if (!MP)
return true;
152 MP->monFlush, MP->monFlash, MP->monIdent,
153 MP->monRnums, MP->monFbsz,
154 MP->monFSint, MP->monFSopt, MP->monFSion);
159 MP->monDest[1], MP->monMode[1]);
168 ConfigGStream(xrootdEnv, pi->
theEnv);
176 if (MP->monDest[0]) MP->Exported();
241 int i, xmode=0, *flushDest;
242 bool haveWord =
true;
246 if ((val =
Config.GetWord()) && !strcmp(
"...", val)) val =
Config.GetWord();
247 else if (MP) {
delete MP; MP = 0;}
251 if (!MP) MP =
new MonParms;
256 {
eDest.
Emsg(
"Config",
"no monitor parameters specified");
262 while(haveWord || (val =
Config.GetWord()))
265 else if (!strcmp(
"auth", val))
267 else if (!strcmp(
"flush", val))
268 {
if ((val =
Config.GetWord()) && !strcmp(
"io", val))
269 { flushDest = &MP->monFlash; val =
Config.GetWord();}
270 else flushDest = &MP->monFlush;
272 {
eDest.
Emsg(
"Config",
"monitor flush value not specified");
276 flushDest,1))
return 1;
278 else if (!strcmp(
"fstat",val))
279 {
if (!(val =
Config.GetWord()))
280 {
eDest.
Emsg(
"Config",
"monitor fstat value not specified");
284 &MP->monFSint,0))
return 1;
285 while((val =
Config.GetWord()))
289 else if (!strcmp(
"xfr", val))
290 {
if (!(val =
Config.GetWord()))
291 {
eDest.
Emsg(
"Config",
"monitor fstat xfr count not specified");
295 val, &MP->monFSion,1))
return 1;
298 else {haveWord =
true;
break;}
300 else if (!strcmp(
"mbuff", val) || !strcmp(
"rbuff", val) ||
301 !strcmp(
"gbuff", val) || !strcmp(
"fbuff", val) ||
302 !strcmp(
"fbsz", val))
303 {
char bName[16], bType = *val;
304 snprintf(bName,
sizeof(bName),
"monitor %s",val);
305 if (!(val =
Config.GetWord()))
306 {
eDest.
Emsg(
"Config",
"value not specified");
return 1;}
309 int bVal =
static_cast<int>(tempval);
311 {
case 'f': MP->monFbsz = bVal;
break;
312 case 'g': MP->monGBval = bVal;
break;
313 case 'm': MP->monMBval = bVal;
break;
314 case 'r': MP->monRBval = bVal;
break;
318 else if (!strcmp(
"ident", val))
319 {
if (!(val =
Config.GetWord()))
320 {
eDest.
Emsg(
"Config",
"monitor ident value not specified");
323 if (!strcmp(
"off", val)) MP->monIdent = -1;
325 &MP->monIdent,0))
return 1;
327 else if (!strcmp(
"rnums", val))
328 {
if (!(val =
Config.GetWord()))
329 {
eDest.
Emsg(
"Config",
"monitor rnums value not specified");
335 else if (!strcmp(
"window", val))
336 {
if (!(val =
Config.GetWord()))
337 {
eDest.
Emsg(
"Config",
"monitor window value not specified");
341 &MP->monWWval,1))
return 1;
348 for (i = 0; i < 2; i++)
349 {
if (strcmp(
"dest", val))
break;
350 while((val =
Config.GetWord()))
366 if (!val) {
eDest.
Emsg(
"Config",
"monitor dest value not specified");
369 if (MP->monDest[i]) free(MP->monDest[i]);
370 if (!(MP->monDest[i] = xmondest(
"monitor dest", val)))
return 1;
371 if (!(val =
Config.GetWord()))
break;
375 {
if (!strcmp(
"dest", val))
376 eDest.
Emsg(
"Config",
"Warning, a maximum of two dest values allowed.");
377 else eDest.
Emsg(
"Config",
"Warning, invalid monitor option", val);
382 if (MP->monDest[0] && MP->monDest[1]
383 && !strcmp(MP->monDest[0], MP->monDest[1]))
384 {
eDest.
Emsg(
"Config",
"Warning, monitor dests are identical.");
385 MP->monMode[0] |= MP->monMode[1]; MP->monMode[1] = 0;
386 free(MP->monDest[1]); MP->monDest[1] = 0;
396 #if !defined(__solaris__) || !defined(_IEEE_754)
397 if (MP->monFSopt &
XROOTD_MON_FSSSQ && !(std::numeric_limits<double>::is_iec559))
399 eDest.
Emsg(
"Config",
"Warning, 'fstat ssq' ignored; platform does not "
400 "use IEEE754 floating point.");
420 char *XrdXrootdProtocol::xmondest(
const char *what,
char *val)
428 if ((eText = netdest.
Set(val)))
429 {
eDest.
Emsg(
"Config", what,
"endpoint is invalid;", eText);
436 {
eDest.
Emsg(
"Config", what,
"endpoint is unreachable");
442 return strdup(netBuff);
475 static const int isFlush = 0;
476 static const int isMaxL = 1;
477 static const int isSend = 2;
479 struct gsOpts {
const char *opname;
int opwhat;} gsopts[] =
484 int numopts =
sizeof(gsopts)/
sizeof(
struct gsOpts);
489 int i, selMon = 0, opt = -1, hdr = -1, fmt = -1, flushVal = -1;
490 long long maxlVal = -1;
491 char *val, *dest = 0;
495 if (!(val =
Config.GetWord()))
496 {
eDest.
Emsg(
"config",
"gstream parameters not specified");
return 1;}
500 do {
if (!strcmp(
"all", val)) selMon = selAll;
501 else {
for (i = 0; i < numgs; i++)
502 {
if (!strcasecmp(val, gsObj[i].pin))
503 {selMon |= gsObj[i].Mode;
break;}
505 if (i >= numgs)
break;
507 }
while((val =
Config.GetWord()));
510 {
eDest.
Emsg(
"config",
"gstream name not specified");
return 1;}
515 {
if (strcmp(val,
"use"))
516 {
eDest.
Emsg(
"config",
"mongstream expected 'use' not",val);
return 1;}
517 if (!(val =
Config.GetWord()))
518 {
eDest.
Emsg(
"config",
"gstream parameters not specified after 'use'");
522 eDest.
Emsg(
"config",
"mongstream expected 'use' verb not found");
528 do{
for (i = 0; i < numopts; i++)
529 {
if (!strcmp(val, gsopts[i].opname))
530 {
if (!(val =
Config.GetWord()))
531 {
eDest.
Emsg(
"Config",
"gstream", gsopts[i].opname,
532 "value not specified");
542 {
eDest.
Emsg(
"config",
"invalid gstream parameter", val);
548 switch(gsopts[i].opwhat)
555 val, &maxlVal, 1024, 65535))
return 1;
558 if (dest) free(dest);
559 if (!xmongsend(Config, val, dest, opt, fmt, hdr))
return 1;
564 }
while((val =
Config.GetWord()));
568 for (i = 0; i < numgs; i++)
569 {
if (gsObj[i].
Mode & selMon)
571 {
if (gsObj[i].dest) free((
void *)gsObj[i].dest);
572 gsObj[i].dest = dest;
574 if (flushVal >= 0) gsObj[i].flsT = flushVal;
575 if (maxlVal >= 0) gsObj[i].maxL = maxlVal;
576 if (opt >= 0) gsObj[i].Opt = opt;
577 if (fmt >= 0) gsObj[i].Fmt = fmt;
578 if (hdr >= 0) gsObj[i].Hdr = hdr;
590 int &opt,
int &fmt,
int &hdr)
592 struct gsFmts {
const char *opname;
int opval;} gsfmt[] =
598 int numfmts =
sizeof(gsfmt)/
sizeof(
struct gsFmts);
600 struct gsHdrs {
const char *opname;
int opval;} gshdr[] =
608 int numhdrs =
sizeof(gshdr)/
sizeof(
struct gsHdrs);
614 for (i = 0; i < numfmts; i++)
615 if (!strcmp(val, gsfmt[i].opname))
616 {fmt = gsfmt[i].opval;
break;}
618 {
eDest.
Emsg(
"Config",
"gstream send format is invalid -", val);
627 {
for (i = 0; i < numhdrs; i++)
628 if (!strcmp(val, gshdr[i].opname))
629 {hdr = gshdr[i].opval;
637 if (val && !strcmp(val,
"noident"))
645 {
eDest.
Emsg(
"Config",
"gstream send endpoint not specified");
651 dest = xmondest(
"gstream send", val);
const kXR_char XROOTD_MON_GSTPC
const kXR_char XROOTD_MON_GSTCP
const kXR_char XROOTD_MON_GSOSS
const kXR_char XROOTD_MON_GSCCM
const kXR_char XROOTD_MON_GSTHR
const kXR_char XROOTD_MON_GSPFC
int Format(char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0)
@ fmtName
Hostname if it is resolvable o/w use fmtAddr.
const char * Set(const char *hSpec, int pNum=PortInSpec)
void * GetPtr(const char *varname)
void PutPtr(const char *varname, void *value)
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdSysLogger * logger(XrdSysLogger *lp=0)
static const int hdrNone
Format as JSON info.
const char * dest
Destination for records.
static const int hdrInst
Include site, host, port, inst.
static const int fmtBin
Do not include info.
XrdXrootdGSReal(const GSParms &gsParms, bool &aOK)
static const int fmtJson
Format as CGI info.
int maxL
Maximum packet length (default 32K)
static const int hdrSite
Include site.
const char * pin
the plugin name.
static const int hdrHost
Include site, host.
static const int optNoID
Don't send ident records.
static const int hdrNorm
Include standard header.
static const int fmtCgi
Format as binary info.
static const int hdrFull
Include site, host, port, inst, pgm.
static void Defaults(char *dest1, int m1, char *dest2, int m2)
static bool ModeEnabled(int mode)
static const char * myInst
static XrdSysError & eDest
static XrdScheduler * Sched