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]);
106 XrdXrootdGStream *gs;
107 static const int numgs=
sizeof(gsObj)/
sizeof(
struct XrdXrootdGSReal::GSParms);
109 bool aOK, gXrd[numgs] = {
false,
false,
true,
false,
true,
false,
true};
114 for (
int i = 0; i < numgs; i++)
116 {
if (MP && gsObj[i].maxL <= 0) gsObj[i].maxL = MP->monGBval;
117 gs =
new XrdXrootdGSReal(gsObj[i], aOK);
118 if (!aOK)
return false;
119 snprintf(vbuff,
sizeof(vbuff),
"%s.gStream*", gsObj[i].pin);
120 if (!gXrd[i]) myEnv.
PutPtr(vbuff, (
void *)gs);
121 else if (urEnv) urEnv->
PutPtr(vbuff, (
void *)gs);
127 if (urEnv && (gs = (XrdXrootdGStream*)urEnv->
GetPtr(
"Tpc.gStream*")))
128 {XrdXrootdTpcMon*
tpcMon =
new XrdXrootdTpcMon(
"xroot",
eDest.logger(),*gs);
129 myEnv.
PutPtr(
"TpcMonitor*", (
void*)tpcMon);
143 int i, numgs =
sizeof(gsObj)/
sizeof(
struct XrdXrootdGSReal::GSParms);
147 for (i = 0; i < numgs && !gsObj[i].dest; i++);
148 if (i < numgs && !MP) MP =
new MonParms;
149 else if (!MP)
return true;
154 MP->monFlush, MP->monFlash, MP->monIdent,
155 MP->monRnums, MP->monFbsz,
156 MP->monFSint, MP->monFSopt, MP->monFSion);
161 MP->monDest[1], MP->monMode[1]);
170 ConfigGStream(xrootdEnv, pi->
theEnv);
178 if (MP->monDest[0]) MP->Exported();
243 int i, xmode=0, *flushDest;
244 bool haveWord =
true;
248 if ((val = Config.GetWord()) && !strcmp(
"...", val)) val = Config.GetWord();
249 else if (MP) {
delete MP; MP = 0;}
253 if (!MP) MP =
new MonParms;
258 {
eDest.Emsg(
"Config",
"no monitor parameters specified");
264 while(haveWord || (val = Config.GetWord()))
267 else if (!strcmp(
"auth", val))
269 else if (!strcmp(
"flush", val))
270 {
if ((val = Config.GetWord()) && !strcmp(
"io", val))
271 { flushDest = &MP->monFlash; val = Config.GetWord();}
272 else flushDest = &MP->monFlush;
274 {
eDest.Emsg(
"Config",
"monitor flush value not specified");
278 flushDest,1))
return 1;
280 else if (!strcmp(
"fstat",val))
281 {
if (!(val = Config.GetWord()))
282 {
eDest.Emsg(
"Config",
"monitor fstat value not specified");
286 &MP->monFSint,0))
return 1;
287 while((val = Config.GetWord()))
291 else if (!strcmp(
"xfr", val))
292 {
if (!(val = Config.GetWord()))
293 {
eDest.Emsg(
"Config",
"monitor fstat xfr count not specified");
297 val, &MP->monFSion,1))
return 1;
300 else {haveWord =
true;
break;}
302 else if (!strcmp(
"mbuff", val) || !strcmp(
"rbuff", val) ||
303 !strcmp(
"gbuff", val) || !strcmp(
"fbuff", val) ||
304 !strcmp(
"fbsz", val))
305 {
char bName[16], bType = *val;
306 snprintf(bName,
sizeof(bName),
"monitor %s",val);
307 if (!(val = Config.GetWord()))
308 {
eDest.Emsg(
"Config",
"value not specified");
return 1;}
311 int bVal =
static_cast<int>(tempval);
313 {
case 'f': MP->monFbsz = bVal;
break;
314 case 'g': MP->monGBval = bVal;
break;
315 case 'm': MP->monMBval = bVal;
break;
316 case 'r': MP->monRBval = bVal;
break;
320 else if (!strcmp(
"ident", val))
321 {
if (!(val = Config.GetWord()))
322 {
eDest.Emsg(
"Config",
"monitor ident value not specified");
325 if (!strcmp(
"off", val)) MP->monIdent = -1;
327 &MP->monIdent,0))
return 1;
329 else if (!strcmp(
"rnums", val))
330 {
if (!(val = Config.GetWord()))
331 {
eDest.Emsg(
"Config",
"monitor rnums value not specified");
337 else if (!strcmp(
"window", val))
338 {
if (!(val = Config.GetWord()))
339 {
eDest.Emsg(
"Config",
"monitor window value not specified");
343 &MP->monWWval,1))
return 1;
350 for (i = 0; i < 2; i++)
351 {
if (strcmp(
"dest", val))
break;
352 while((val = Config.GetWord()))
358 else if (!strcmp(
"io", val)) MP->monMode[i] |=
XROOTD_MON_IO;
359 else if (!strcmp(
"iov", val)) MP->monMode[i] |= (
XROOTD_MON_IO
369 if (!val) {
eDest.Emsg(
"Config",
"monitor dest value not specified");
372 if (MP->monDest[i]) free(MP->monDest[i]);
373 if (!(MP->monDest[i] = xmondest(
"monitor dest", val)))
return 1;
374 if (!(val = Config.GetWord()))
break;
378 {
if (!strcmp(
"dest", val))
379 eDest.Emsg(
"Config",
"Warning, a maximum of two dest values allowed.");
380 else eDest.Emsg(
"Config",
"Warning, invalid monitor option", val);
385 if (MP->monDest[0] && MP->monDest[1]
386 && !strcmp(MP->monDest[0], MP->monDest[1]))
387 {
eDest.Emsg(
"Config",
"Warning, monitor dests are identical.");
388 MP->monMode[0] |= MP->monMode[1]; MP->monMode[1] = 0;
389 free(MP->monDest[1]); MP->monDest[1] = 0;
399#if !defined(__solaris__) || !defined(_IEEE_754)
400 if (MP->monFSopt &
XROOTD_MON_FSSSQ && !(std::numeric_limits<double>::is_iec559))
401 {MP->monFSopt &= ~XROOTD_MON_FSSSQ;
402 eDest.Emsg(
"Config",
"Warning, 'fstat ssq' ignored; platform does not "
403 "use IEEE754 floating point.");
423char *XrdXrootdProtocol::xmondest(
const char *what,
char *val)
431 if ((eText = netdest.
Set(val)))
432 {
eDest.Emsg(
"Config", what,
"endpoint is invalid;", eText);
439 {
eDest.Emsg(
"Config", what,
"endpoint is unreachable");
445 return strdup(netBuff);
479 static const int isFlush = 0;
480 static const int isMaxL = 1;
481 static const int isSend = 2;
483 struct gsOpts {
const char *opname;
int opwhat;} gsopts[] =
488 int numopts =
sizeof(gsopts)/
sizeof(
struct gsOpts);
490 int numgs =
sizeof(gsObj)/
sizeof(
struct XrdXrootdGSReal::GSParms);
493 int i, selMon = 0, opt = -1, hdr = -1, fmt = -1, flushVal = -1;
494 long long maxlVal = -1;
495 char *val, *dest = 0;
499 if (!(val = Config.GetWord()))
500 {
eDest.Emsg(
"config",
"gstream parameters not specified");
return 1;}
504do {
if (!strcmp(
"all", val)) selMon = selAll;
505 else {
for (i = 0; i < numgs; i++)
506 {
if (!strcasecmp(val, gsObj[i].pin))
507 {selMon |= gsObj[i].Mode;
break;}
509 if (i >= numgs)
break;
511 }
while((val = Config.GetWord()));
514 {
eDest.Emsg(
"config",
"gstream name not specified");
return 1;}
519 {
if (strcmp(val,
"use"))
520 {
eDest.Emsg(
"config",
"mongstream expected 'use' not",val);
return 1;}
521 if (!(val = Config.GetWord()))
522 {
eDest.Emsg(
"config",
"gstream parameters not specified after 'use'");
526 eDest.Emsg(
"config",
"mongstream expected 'use' verb not found");
532do{
for (i = 0; i < numopts; i++)
533 {
if (!strcmp(val, gsopts[i].opname))
534 {
if (!(val = Config.GetWord()))
535 {
eDest.Emsg(
"Config",
"gstream", gsopts[i].opname,
536 "value not specified");
546 {
eDest.Emsg(
"config",
"invalid gstream parameter", val);
552 switch(gsopts[i].opwhat)
559 val, &maxlVal, 1024, 65535))
return 1;
562 if (dest) free(dest);
563 if (!xmongsend(Config, val, dest, opt, fmt, hdr))
return 1;
568 }
while((val = Config.GetWord()));
572 for (i = 0; i < numgs; i++)
573 {
if (gsObj[i].
Mode & selMon)
575 {
if (gsObj[i].dest) free((
void *)gsObj[i].dest);
576 gsObj[i].dest = dest;
578 if (flushVal >= 0) gsObj[i].flsT = flushVal;
579 if (maxlVal >= 0) gsObj[i].maxL = maxlVal;
580 if (opt >= 0) gsObj[i].Opt = opt;
581 if (fmt >= 0) gsObj[i].Fmt = fmt;
582 if (hdr >= 0) gsObj[i].Hdr = hdr;
593bool XrdXrootdProtocol::xmongsend(
XrdOucStream &Config,
char *val,
char *&dest,
594 int &opt,
int &fmt,
int &hdr)
596 struct gsFmts {
const char *opname;
int opval;} gsfmt[] =
602 int numfmts =
sizeof(gsfmt)/
sizeof(
struct gsFmts);
604 struct gsHdrs {
const char *opname;
int opval;} gshdr[] =
612 int numhdrs =
sizeof(gshdr)/
sizeof(
struct gsHdrs);
618 for (i = 0; i < numfmts; i++)
619 if (!strcmp(val, gsfmt[i].opname))
620 {fmt = gsfmt[i].opval;
break;}
622 {
eDest.Emsg(
"Config",
"gstream send format is invalid -", val);
628 val = Config.GetWord();
631 {
for (i = 0; i < numhdrs; i++)
632 if (!strcmp(val, gshdr[i].opname))
633 {hdr = gshdr[i].opval;
634 val = Config.GetWord();
641 if (val && !strcmp(val,
"noident"))
643 val = Config.GetWord();
649 {
eDest.Emsg(
"Config",
"gstream send endpoint not specified");
655 dest = xmondest(
"gstream send", val);
const kXR_char XROOTD_MON_GSTPC
const kXR_char XROOTD_MON_GSTCP
const kXR_char XROOTD_MON_GSHTP
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)
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