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]);
102 XrdXrootdGStream *gs;
103 static const int numgs=
sizeof(gsObj)/
sizeof(
struct XrdXrootdGSReal::GSParms);
105 bool aOK, gXrd[numgs] = {
false,
false,
true,
false,
true};
110 for (
int i = 0; i < numgs; i++)
112 {
if (MP && gsObj[i].maxL <= 0) gsObj[i].maxL = MP->monGBval;
113 gs =
new XrdXrootdGSReal(gsObj[i], aOK);
114 if (!aOK)
return false;
115 snprintf(vbuff,
sizeof(vbuff),
"%s.gStream*", gsObj[i].pin);
116 if (!gXrd[i]) myEnv.
PutPtr(vbuff, (
void *)gs);
117 else if (urEnv) urEnv->
PutPtr(vbuff, (
void *)gs);
123 if (urEnv && (gs = (XrdXrootdGStream*)urEnv->
GetPtr(
"Tpc.gStream*")))
124 {XrdXrootdTpcMon*
tpcMon =
new XrdXrootdTpcMon(
"xroot",
eDest.logger(),*gs);
125 myEnv.
PutPtr(
"TpcMonitor*", (
void*)tpcMon);
139 int i, numgs =
sizeof(gsObj)/
sizeof(
struct XrdXrootdGSReal::GSParms);
143 for (i = 0; i < numgs && !gsObj[i].dest; i++);
144 if (i < numgs && !MP) MP =
new MonParms;
145 else if (!MP)
return true;
150 MP->monFlush, MP->monFlash, MP->monIdent,
151 MP->monRnums, MP->monFbsz,
152 MP->monFSint, MP->monFSopt, MP->monFSion);
157 MP->monDest[1], MP->monMode[1]);
166 ConfigGStream(xrootdEnv, pi->
theEnv);
174 if (MP->monDest[0]) MP->Exported();
239 int i, xmode=0, *flushDest;
240 bool haveWord =
true;
244 if ((val = Config.GetWord()) && !strcmp(
"...", val)) val = Config.GetWord();
245 else if (MP) {
delete MP; MP = 0;}
249 if (!MP) MP =
new MonParms;
254 {
eDest.Emsg(
"Config",
"no monitor parameters specified");
260 while(haveWord || (val = Config.GetWord()))
263 else if (!strcmp(
"auth", val))
265 else if (!strcmp(
"flush", val))
266 {
if ((val = Config.GetWord()) && !strcmp(
"io", val))
267 { flushDest = &MP->monFlash; val = Config.GetWord();}
268 else flushDest = &MP->monFlush;
270 {
eDest.Emsg(
"Config",
"monitor flush value not specified");
274 flushDest,1))
return 1;
276 else if (!strcmp(
"fstat",val))
277 {
if (!(val = Config.GetWord()))
278 {
eDest.Emsg(
"Config",
"monitor fstat value not specified");
282 &MP->monFSint,0))
return 1;
283 while((val = Config.GetWord()))
287 else if (!strcmp(
"xfr", val))
288 {
if (!(val = Config.GetWord()))
289 {
eDest.Emsg(
"Config",
"monitor fstat xfr count not specified");
293 val, &MP->monFSion,1))
return 1;
296 else {haveWord =
true;
break;}
298 else if (!strcmp(
"mbuff", val) || !strcmp(
"rbuff", val) ||
299 !strcmp(
"gbuff", val) || !strcmp(
"fbuff", val) ||
300 !strcmp(
"fbsz", val))
301 {
char bName[16], bType = *val;
302 snprintf(bName,
sizeof(bName),
"monitor %s",val);
303 if (!(val = Config.GetWord()))
304 {
eDest.Emsg(
"Config",
"value not specified");
return 1;}
307 int bVal =
static_cast<int>(tempval);
309 {
case 'f': MP->monFbsz = bVal;
break;
310 case 'g': MP->monGBval = bVal;
break;
311 case 'm': MP->monMBval = bVal;
break;
312 case 'r': MP->monRBval = bVal;
break;
316 else if (!strcmp(
"ident", val))
317 {
if (!(val = Config.GetWord()))
318 {
eDest.Emsg(
"Config",
"monitor ident value not specified");
321 if (!strcmp(
"off", val)) MP->monIdent = -1;
323 &MP->monIdent,0))
return 1;
325 else if (!strcmp(
"rnums", val))
326 {
if (!(val = Config.GetWord()))
327 {
eDest.Emsg(
"Config",
"monitor rnums value not specified");
333 else if (!strcmp(
"window", val))
334 {
if (!(val = Config.GetWord()))
335 {
eDest.Emsg(
"Config",
"monitor window value not specified");
339 &MP->monWWval,1))
return 1;
346 for (i = 0; i < 2; i++)
347 {
if (strcmp(
"dest", val))
break;
348 while((val = Config.GetWord()))
353 else if (!strcmp(
"io", val)) MP->monMode[i] |=
XROOTD_MON_IO;
354 else if (!strcmp(
"iov", val)) MP->monMode[i] |= (
XROOTD_MON_IO
364 if (!val) {
eDest.Emsg(
"Config",
"monitor dest value not specified");
367 if (MP->monDest[i]) free(MP->monDest[i]);
368 if (!(MP->monDest[i] = xmondest(
"monitor dest", val)))
return 1;
369 if (!(val = Config.GetWord()))
break;
373 {
if (!strcmp(
"dest", val))
374 eDest.Emsg(
"Config",
"Warning, a maximum of two dest values allowed.");
375 else eDest.Emsg(
"Config",
"Warning, invalid monitor option", val);
380 if (MP->monDest[0] && MP->monDest[1]
381 && !strcmp(MP->monDest[0], MP->monDest[1]))
382 {
eDest.Emsg(
"Config",
"Warning, monitor dests are identical.");
383 MP->monMode[0] |= MP->monMode[1]; MP->monMode[1] = 0;
384 free(MP->monDest[1]); MP->monDest[1] = 0;
394#if !defined(__solaris__) || !defined(_IEEE_754)
395 if (MP->monFSopt &
XROOTD_MON_FSSSQ && !(std::numeric_limits<double>::is_iec559))
396 {MP->monFSopt &= ~XROOTD_MON_FSSSQ;
397 eDest.Emsg(
"Config",
"Warning, 'fstat ssq' ignored; platform does not "
398 "use IEEE754 floating point.");
418char *XrdXrootdProtocol::xmondest(
const char *what,
char *val)
426 if ((eText = netdest.
Set(val)))
427 {
eDest.Emsg(
"Config", what,
"endpoint is invalid;", eText);
434 {
eDest.Emsg(
"Config", what,
"endpoint is unreachable");
440 return strdup(netBuff);
473 static const int isFlush = 0;
474 static const int isMaxL = 1;
475 static const int isSend = 2;
477 struct gsOpts {
const char *opname;
int opwhat;} gsopts[] =
482 int numopts =
sizeof(gsopts)/
sizeof(
struct gsOpts);
484 int numgs =
sizeof(gsObj)/
sizeof(
struct XrdXrootdGSReal::GSParms);
487 int i, selMon = 0, opt = -1, hdr = -1, fmt = -1, flushVal = -1;
488 long long maxlVal = -1;
489 char *val, *dest = 0;
493 if (!(val = Config.GetWord()))
494 {
eDest.Emsg(
"config",
"gstream parameters not specified");
return 1;}
498do {
if (!strcmp(
"all", val)) selMon = selAll;
499 else {
for (i = 0; i < numgs; i++)
500 {
if (!strcasecmp(val, gsObj[i].pin))
501 {selMon |= gsObj[i].Mode;
break;}
503 if (i >= numgs)
break;
505 }
while((val = Config.GetWord()));
508 {
eDest.Emsg(
"config",
"gstream name not specified");
return 1;}
513 {
if (strcmp(val,
"use"))
514 {
eDest.Emsg(
"config",
"mongstream expected 'use' not",val);
return 1;}
515 if (!(val = Config.GetWord()))
516 {
eDest.Emsg(
"config",
"gstream parameters not specified after 'use'");
520 eDest.Emsg(
"config",
"mongstream expected 'use' verb not found");
526do{
for (i = 0; i < numopts; i++)
527 {
if (!strcmp(val, gsopts[i].opname))
528 {
if (!(val = Config.GetWord()))
529 {
eDest.Emsg(
"Config",
"gstream", gsopts[i].opname,
530 "value not specified");
540 {
eDest.Emsg(
"config",
"invalid gstream parameter", val);
546 switch(gsopts[i].opwhat)
553 val, &maxlVal, 1024, 65535))
return 1;
556 if (dest) free(dest);
557 if (!xmongsend(Config, val, dest, opt, fmt, hdr))
return 1;
562 }
while((val = Config.GetWord()));
566 for (i = 0; i < numgs; i++)
567 {
if (gsObj[i].
Mode & selMon)
569 {
if (gsObj[i].dest) free((
void *)gsObj[i].dest);
570 gsObj[i].dest = dest;
572 if (flushVal >= 0) gsObj[i].flsT = flushVal;
573 if (maxlVal >= 0) gsObj[i].maxL = maxlVal;
574 if (opt >= 0) gsObj[i].Opt = opt;
575 if (fmt >= 0) gsObj[i].Fmt = fmt;
576 if (hdr >= 0) gsObj[i].Hdr = hdr;
587bool XrdXrootdProtocol::xmongsend(
XrdOucStream &Config,
char *val,
char *&dest,
588 int &opt,
int &fmt,
int &hdr)
590 struct gsFmts {
const char *opname;
int opval;} gsfmt[] =
596 int numfmts =
sizeof(gsfmt)/
sizeof(
struct gsFmts);
598 struct gsHdrs {
const char *opname;
int opval;} gshdr[] =
606 int numhdrs =
sizeof(gshdr)/
sizeof(
struct gsHdrs);
612 for (i = 0; i < numfmts; i++)
613 if (!strcmp(val, gsfmt[i].opname))
614 {fmt = gsfmt[i].opval;
break;}
616 {
eDest.Emsg(
"Config",
"gstream send format is invalid -", val);
622 val = Config.GetWord();
625 {
for (i = 0; i < numhdrs; i++)
626 if (!strcmp(val, gshdr[i].opname))
627 {hdr = gshdr[i].opval;
628 val = Config.GetWord();
635 if (val && !strcmp(val,
"noident"))
637 val = Config.GetWord();
643 {
eDest.Emsg(
"Config",
"gstream send endpoint not specified");
649 dest = xmondest(
"gstream send", val);
const kXR_char XROOTD_MON_GSTPC
const kXR_char XROOTD_MON_GSTCP
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)
static const int hdrNone
Format as JSON info.
static const int hdrInst
Include site, host, port, inst.
static const int fmtBin
Do not include info.
static const int fmtJson
Format as CGI info.
static const int hdrSite
Include site.
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