XRootD
Loading...
Searching...
No Matches
XrdXrootdMonitor Class Reference

#include <XrdXrootdMonitor.hh>

Collaboration diagram for XrdXrootdMonitor:

Classes

class  Hello
class  User

Public Member Functions

 XrdXrootdMonitor ()
void Add_rd (kXR_unt32 dictid, kXR_int32 rlen, kXR_int64 offset)
void Add_rv (kXR_unt32 dictid, kXR_int32 rlen, kXR_int16 vcnt, kXR_char vseq, kXR_char vtype)
void Add_wr (kXR_unt32 dictid, kXR_int32 wlen, kXR_int64 offset)
void appID (char *id)
void Close (kXR_unt32 dictid, long long rTot, long long wTot)
void Disc (kXR_unt32 dictid, int csec, char Flags=0)
void Open (kXR_unt32 dictid, off_t fsize)

Static Public Member Functions

static int CopyText (char *buff, int room, const char *text, int tLen)
static void Defaults (char *dest1, int m1, char *dest2, int m2)
static void Defaults (int msz, int rsz, int wsz, int flush, int flash, int iDent, int rnm, int fbsz, int fsint=0, int fsopt=0, int fsion=0)
static int Flushing ()
static kXR_unt32 GetDictID (bool hbo=false)
static void Ident ()
static int Init ()
static void Init (XrdScheduler *sp, XrdSysError *errp, const char *iHost, const char *iProg, const char *iName, int Port)
static bool ModeEnabled (int mode)
static int Redirect ()
static int Redirect (kXR_unt32 mID, const char *hName, int Port, const char opC, const char *Path)
static int Send (int mmode, void *buff, int size, bool setseq=true)
static time_t Tick ()

Static Public Attributes

static XrdXrootdMonitor * altMon = 0
static constexpr int maxDgram = 65507
static const int rdrMax = 8

Friends

class User
class XrdXrootdMonFile

Detailed Description

Definition at line 80 of file XrdXrootdMonitor.hh.

Constructor & Destructor Documentation

◆ XrdXrootdMonitor()

XrdXrootdMonitor::XrdXrootdMonitor ( )

Definition at line 368 of file XrdXrootdMonitor.cc.

369{
370 kXR_int32 localWindow;
371
372// Initialize last window to force a mark as well as the local window
373//
374 lastWindow = 0;
375 localWindow = currWindow;
376
377// Allocate a monitor buffer
378//
379 if (posix_memalign((void **)&monBuff, getpagesize(), monBlen))
380 eDest->Emsg("Monitor", "Unable to allocate monitor buffer.");
381 else {nextEnt = 1;
382 setTMark(monBuff, 0, localWindow);
383 }
384}
int kXR_int32
Definition XPtypes.hh:89
XrdSysError eDest(0, "HttpMon")
#define setTMark(TM_mb, TM_en, TM_tm)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)

References eDest, XrdSysError::Emsg(), and setTMark.

Referenced by Init().

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

Member Function Documentation

◆ Add_rd()

void XrdXrootdMonitor::Add_rd ( kXR_unt32 dictid,
kXR_int32 rlen,
kXR_int64 offset )
inline

Definition at line 89 of file XrdXrootdMonitor.hh.

92 {Add_io(dictid, rlen, offset);}

◆ Add_rv()

void XrdXrootdMonitor::Add_rv ( kXR_unt32 dictid,
kXR_int32 rlen,
kXR_int16 vcnt,
kXR_char vseq,
kXR_char vtype )
inline

Definition at line 94 of file XrdXrootdMonitor.hh.

99 {if (lastWindow != currWindow) Mark();
100 else if (nextEnt == lastEnt) Flush();
101 monBuff->info[nextEnt].arg0.id[0] = vtype;
102 monBuff->info[nextEnt].arg0.id[1] = vseq;
103 monBuff->info[nextEnt].arg0.sVal[1] = vcnt;
104 monBuff->info[nextEnt].arg0.rTot[1] = 0;
105 monBuff->info[nextEnt].arg1.buflen = rlen;
106 monBuff->info[nextEnt++].arg2.dictid = dictid;
107 }

◆ Add_wr()

void XrdXrootdMonitor::Add_wr ( kXR_unt32 dictid,
kXR_int32 wlen,
kXR_int64 offset )
inline

Definition at line 109 of file XrdXrootdMonitor.hh.

112 {Add_io(dictid,(kXR_int32)htonl(-wlen),offset);}

Referenced by XrdXrootdProtocol::do_WriteSpan().

Here is the caller graph for this function:

◆ appID()

void XrdXrootdMonitor::appID ( char * id)

Definition at line 400 of file XrdXrootdMonitor.cc.

401{
402 static const int apInfoSize = sizeof(XrdXrootdMonTrace)-4;
403
404// Application ID's are only meaningful for io event recording
405//
406 if (this == altMon || !*id) return;
407
408// Fill out the monitor record
409//
410 if (lastWindow != currWindow) Mark();
411 else if (nextEnt == lastEnt) Flush();
412 monBuff->info[nextEnt].arg0.id[0] = XROOTD_MON_APPID;
413 strncpy((char *)(&(monBuff->info[nextEnt])+4), id, apInfoSize);
414}
const kXR_char XROOTD_MON_APPID
static XrdXrootdMonitor * altMon

References altMon, and XROOTD_MON_APPID.

◆ Close()

void XrdXrootdMonitor::Close ( kXR_unt32 dictid,
long long rTot,
long long wTot )

Definition at line 452 of file XrdXrootdMonitor.cc.

453{
454 XrdXrootdMonitorLock mLock(this);
455 unsigned int rVal, wVal;
456
457// Fill out the monitor record (we allow the compiler to correctly cast data)
458//
459 if (lastWindow != currWindow) Mark();
460 else if (nextEnt == lastEnt) Flush();
461 monBuff->info[nextEnt].arg0.id[0] = XROOTD_MON_CLOSE;
462 monBuff->info[nextEnt].arg0.id[1] = do_Shift(rTot, rVal);
463 monBuff->info[nextEnt].arg0.rTot[1] = htonl(rVal);
464 monBuff->info[nextEnt].arg0.id[2] = do_Shift(wTot, wVal);
465 monBuff->info[nextEnt].arg0.id[3] = 0;
466 monBuff->info[nextEnt].arg1.wTot = htonl(wVal);
467 monBuff->info[nextEnt++].arg2.dictid = dictid;
468
469// Check if we need to duplicate this entry
470//
471 if (altMon && this != altMon) altMon->Dup(&monBuff->info[nextEnt-1]);
472}
const kXR_char XROOTD_MON_CLOSE

References altMon, and XROOTD_MON_CLOSE.

Referenced by XrdXrootdFileTable::Del(), and XrdXrootdFileTable::Recycle().

Here is the caller graph for this function:

◆ CopyText()

int XrdXrootdMonitor::CopyText ( char * buff,
int room,
const char * text,
int tLen )
static

Copy text that a record binds to a dictid. At most room-1 characters are copied, and null bytes fill the rest of the room.

Parameters
buffPointer to the room in the record.
roomSize of the room, in bytes.
textPointer to the text.
tLenLength of the text, as given by strlen().
Returns
The number of characters copied, not counting the null bytes.

Definition at line 478 of file XrdXrootdMonitor.cc.

479{
480// A record that binds text to a dictid must fit its buffer. So truncate the
481// text, rather than drop the record, and null pad the rest of the buffer. At
482// least one null byte always ends the text. The caller gives the length of
483// the text, because it needs the length to size the record.
484//
485 if (room <= 0) return 0;
486 if (tLen > room - 1) tLen = room - 1;
487 memcpy(buff, text, tLen);
488 memset(buff + tLen, 0, room - tLen);
489 return tLen;
490}

Referenced by XrdXrootdMonFile::Open(), and Redirect().

Here is the caller graph for this function:

◆ Defaults() [1/2]

void XrdXrootdMonitor::Defaults ( char * dest1,
int m1,
char * dest2,
int m2 )
static

Definition at line 498 of file XrdXrootdMonitor.cc.

499{
500 int mmode;
501
502// If there are no destination then only g-stream events may be enabled.
503// Otherwise, sort out the destinations relative to modes.
504//
505 if (!dest1 && !dest2) {isEnabled = 0; return;}
506 if (!dest1) {dest1 = dest2; dest2 = 0; mode1 |= mode2; mode2 = 0;}
507
508// Set the default destinations (caller supplied strdup'd strings)
509//
510 if (Dest1) free(Dest1);
511 Dest1 = dest1; monMode1 = mode1;
512 if (Dest2) free(Dest2);
513 Dest2 = dest2; monMode2 = mode2;
514
515// Set overall monitor mode
516//
517 mmode = mode1 | mode2;
518 monACTIVE = (mmode ? 1 : 0);
519 isEnabled = (mmode & XROOTD_MON_ALL ? 1 :-1);
520 monIO = (mmode & XROOTD_MON_IO ? 1 : 0);
521 monIO = (mmode & XROOTD_MON_IOV ? 2 : monIO);
522 monINFO = (mmode & XROOTD_MON_INFO ? 1 : 0);
523 monFILE = (mmode & XROOTD_MON_FILE ? 1 : 0) | monIO;
524 monREDR = (mmode & XROOTD_MON_REDR ? 1 : 0);
525 monUSER = (mmode & XROOTD_MON_USER ? 1 : 0);
526 monAUTH = (mmode & XROOTD_MON_AUTH ? 1 : 0);
527 monFSTAT = (mmode & XROOTD_MON_FSTA && monFSTAT ? 1 : 0);
528
529// Compute whether or not we need the clock running
530//
531 if (monREDR || (isEnabled > 0 && (monIO || monFILE))) monCLOCK = 1;
532
533// Check where user information should go
534//
535 if (((mode1 & XROOTD_MON_IO) && (mode1 & XROOTD_MON_USER))
536 || ((mode2 & XROOTD_MON_IO) && (mode2 & XROOTD_MON_USER)))
537 {if ((!(mode1 & XROOTD_MON_IO) && (mode1 & XROOTD_MON_USER))
538 || (!(mode2 & XROOTD_MON_IO) && (mode2 & XROOTD_MON_USER))) monUSER = 3;
539 else monUSER = 2;
540 }
541
542// If we are monitoring redirections then set an envar saying how often idents
543// should be sent (this also tips off other layers to handle such monitoring)
544//
545 if (monREDR) XrdOucEnv::Export("XRDMONRDR", monIdent);
546}
#define XROOTD_MON_IOV
#define XROOTD_MON_INFO
#define XROOTD_MON_ALL
#define XROOTD_MON_AUTH
#define XROOTD_MON_IO
#define XROOTD_MON_USER
#define XROOTD_MON_FSTA
#define XROOTD_MON_FILE
#define XROOTD_MON_REDR
static int Export(const char *Var, const char *Val)
Definition XrdOucEnv.cc:170

References XrdOucEnv::Export(), XROOTD_MON_ALL, XROOTD_MON_AUTH, XROOTD_MON_FILE, XROOTD_MON_FSTA, XROOTD_MON_INFO, XROOTD_MON_IO, XROOTD_MON_IOV, XROOTD_MON_REDR, and XROOTD_MON_USER.

Here is the call graph for this function:

◆ Defaults() [2/2]

void XrdXrootdMonitor::Defaults ( int msz,
int rsz,
int wsz,
int flush,
int flash,
int iDent,
int rnm,
int fbsz,
int fsint = 0,
int fsopt = 0,
int fsion = 0 )
static

Definition at line 550 of file XrdXrootdMonitor.cc.

553{
554
555// Set default window size and flush time
556//
557 sizeWindow = (wsz <= 0 ? 60 : wsz);
558 autoFlush = (flush <= 0 ? 600 : flush);
559 autoFlash = (flash <= 0 ? 0 : flash);
560 monIdent = idt;
561 rdrNum = (rnm <= 0 || rnm > rdrMax ? 3 : rnm);
562 rdrWin = (sizeWindow > 16777215 ? 16777215 : sizeWindow);
563 rdrWin = htonl(rdrWin);
564
565// Set the fstat defaults
566//
567 XrdXrootdMonFile::Defaults(fsint, fsopt, fsion, fbsz);
568 monFSTAT = fsint != 0;
569
570// Set default monitor buffer size. The configuration accepts up to 65535
571// bytes, but the buffer goes out as one datagram, so limit it to maxDgram.
572//
573 if (msz <= 0) msz = 16384;
574 else if (msz < 1024) msz = 1024;
575 else {if (msz > maxDgram) msz = maxDgram;
576 msz = msz/sizeof(XrdXrootdMonTrace)*sizeof(XrdXrootdMonTrace);
577 }
578 lastEnt = (msz-sizeof(XrdXrootdMonHeader))/sizeof(XrdXrootdMonTrace);
579 monBlen = (lastEnt*sizeof(XrdXrootdMonTrace))+sizeof(XrdXrootdMonHeader);
580 lastEnt--;
581
582// Set default monitor redirect buffer size
583//
584 if (rsz <= 0) rsz = 32768;
585 else if (rsz < 2048) rsz = 2048;
586 lastRnt = (rsz-(sizeof(XrdXrootdMonHeader) + 16))/sizeof(XrdXrootdMonRedir);
587 monRlen = (lastRnt*sizeof(XrdXrootdMonRedir))+sizeof(XrdXrootdMonHeader)+16;
588 lastRnt--;
589}
static void Defaults(int intv, int opts, int iocnt, int fbsz)
static const int rdrMax
static constexpr int maxDgram

References XrdXrootdMonFile::Defaults(), maxDgram, and rdrMax.

Here is the call graph for this function:

◆ Disc()

void XrdXrootdMonitor::Disc ( kXR_unt32 dictid,
int csec,
char Flags = 0 )

Definition at line 595 of file XrdXrootdMonitor.cc.

596{
597 XrdXrootdMonitorLock mLock(this);
598
599// Check if this should not be included in the io trace
600//
601 if (this != altMon && monUSER == 1 && altMon)
602 {altMon->Disc(dictid, csec); return;}
603
604// Fill out the monitor record (let compiler cast the data correctly)
605//
606 if (lastWindow != currWindow) Mark();
607 else if (nextEnt == lastEnt) Flush();
608 monBuff->info[nextEnt].arg0.rTot[0] = 0;
609 monBuff->info[nextEnt].arg0.id[0] = XROOTD_MON_DISC;
610 monBuff->info[nextEnt].arg0.id[1] = Flags;
611 monBuff->info[nextEnt].arg1.wTot = htonl(csec);
612 monBuff->info[nextEnt++].arg2.dictid = dictid;
613
614// Check if we need to duplicate this entry
615//
616 if (altMon && this != altMon && monUSER == 3)
617 altMon->Dup(&monBuff->info[nextEnt-1]);
618}
const kXR_char XROOTD_MON_DISC
void Disc(kXR_unt32 dictid, int csec, char Flags=0)

References altMon, Disc(), and XROOTD_MON_DISC.

Referenced by Disc(), and XrdXrootdProtocol::Recycle().

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

◆ Flushing()

int XrdXrootdMonitor::Flushing ( )
inlinestatic

Definition at line 138 of file XrdXrootdMonitor.hh.

138{return autoFlush;}

Referenced by XrdXrootdGSReal::XrdXrootdGSReal().

Here is the caller graph for this function:

◆ GetDictID()

kXR_unt32 XrdXrootdMonitor::GetDictID ( bool hbo = false)
static

Definition at line 839 of file XrdXrootdMonitor.cc.

840{
841 static XrdSysMutex seqMutex;
842 static unsigned int monSeqID = 1;
843 unsigned int mySeqID;
844
845// Assign a unique ID for this entry
846//
847 seqMutex.Lock();
848 mySeqID = monSeqID++;
850
851// Return the ID
852//
853 if (hbo) return mySeqID;
854 return htonl(mySeqID);
855}

References XrdSysMutex::Lock(), XrdXrootdMonInfo::seqMutex, and XrdSysMutex::UnLock().

Referenced by XrdXrootdGSReal::GetDictID(), and XrdXrootdMonFile::Open().

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

◆ Ident()

void XrdXrootdMonitor::Ident ( )
inlinestatic

Definition at line 142 of file XrdXrootdMonitor.hh.

142{Send(-1, idRec, idLen);}
static int Send(int mmode, void *buff, int size, bool setseq=true)

References Send().

Referenced by XrdXrootdMonitor_Ident::DoIt().

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

◆ Init() [1/2]

int XrdXrootdMonitor::Init ( )
static

Definition at line 755 of file XrdXrootdMonitor.cc.

756{
757 static XrdXrootdMonitor_Ident MonIdent(monIdent, isEnabled);
758 int i, Now = time(0);
759 bool aOK;
760
761// Setup the primary destination
762//
763 if (Dest1)
764 {InetDest1 = new XrdNetMsg(eDest, Dest1, &aOK, true);
765 if (!aOK)
766 {eDest->Emsg("Monitor", "Unable to setup primary monitor collector.");
767 return 0;
768 }
769 }
770
771// Setup the secondary destination
772//
773 if (Dest2)
774 {InetDest2 = new XrdNetMsg(eDest, Dest2, &aOK, true);
775 if (!aOK)
776 {eDest->Emsg("Monitor","Unable to setup secondary monitor collector.");
777 return 0;
778 }
779 }
780
781// Now schedule the first identification record
782//
783 if (Sched && monIdent >= 0) Sched->Schedule((XrdJob *)&MonIdent);
784
785// There is nothing more to do unless we have been enabled via Defaults()
786//
787 if (!isEnabled) return 1;
788
789// If there is a destination that is only collecting file events, then
790// allocate a global monitor object but don't start the timer just yet.
791//
792 if ((monMode1 && !(monMode1 & XROOTD_MON_IO))
793 || (monMode2 && !(monMode2 & XROOTD_MON_IO)))
794 if (!(altMon = new XrdXrootdMonitor()) || !altMon->monBuff)
795 {if (altMon) {delete altMon; altMon = 0;}
796 eDest->Emsg("Monitor","allocate monitor; insufficient storage.");
797 return 0;
798 }
799
800// Turn on the monitoring clock if we need it running all the time
801//
802 if (monCLOCK) startClock();
803
804// If we are monitoring file stats then start that up
805//
806 if (!Sched || !monFSTAT) monFSTAT = 0;
807 else if (!XrdXrootdMonFile::Init()) return 0;
808
809// If we are not monitoring redirections, we are done!
810//
811 if (!monREDR) return 1;
812
813// Allocate as many redirection monitors as requested
814//
815 for (i = 0; i < rdrNum; i++)
816 {if (posix_memalign((void **)&rdrMon[i].Buff, getpagesize(),monRlen))
817 {eDest->Emsg("Monitor", "Unable to allocate monitor rdr buffer.");
818 return 0;
819 }
820 rdrMon[i].Buff->sID = mySID;
821 rdrMon[i].Buff->sXX[0] = XROOTD_MON_REDSID;
822 rdrMon[i].Next = (i ? &rdrMon[i-1] : &rdrMon[0]);
823 rdrMon[i].nextEnt = 0;
824 rdrMon[i].flushIt = Now + autoFlush;
825 rdrMon[i].lastTOD = 0;
826 }
827 rdrMon[0].Next = &rdrMon[i-1];
828 rdrMP = &rdrMon[0];
829
830// All done
831//
832 return 1;
833}
const kXR_char XROOTD_MON_REDSID
XrdNetMsg(XrdSysError *erp, const char *dest=0, bool *aOK=0, bool refr=false)
Definition XrdNetMsg.cc:66
void Schedule(XrdJob *jp)
XrdScheduler * Sched

References XrdNetMsg::XrdNetMsg(), XrdXrootdMonitor(), altMon, eDest, XrdSysError::Emsg(), XrdXrootdMonFile::Init(), XrdXrootdMonInfo::mySID, XrdXrootdMonInfo::Sched, XrdScheduler::Schedule(), XROOTD_MON_IO, and XROOTD_MON_REDSID.

Here is the call graph for this function:

◆ Init() [2/2]

void XrdXrootdMonitor::Init ( XrdScheduler * sp,
XrdSysError * errp,
const char * iHost,
const char * iProg,
const char * iName,
int Port )
static

Definition at line 656 of file XrdXrootdMonitor.cc.

659{
660 const char *cgID0 = "&site=%s";
661 const char *cgID1 = "&host=%s";
662 const char *cgID2 = "&port=%d&inst=%s";
663 const char *cgID3 = "&pgm=%s&ver=%s";
664
665 const char *jsID0 = "\"src\":{\"site\":\"%s\"}";
666 const char *jsID1 = "%s\"host\":\"%s\"}";
667 const char *jsID2 = "%s\"port\":%d,\"inst\":\"%s\"}";
668 const char *jsID3 = "%s\"pgm\":\"%s\",\"ver\":\"%s\"}";
669
670 XrdXrootdMonMap *mP;
671 char iBuff[1024], iMuff[2048], iPuff[1024];
672 int n, i, j;
673
674// Set static variables
675//
676 Sched = sp;
677 eDest = errp;
678
679// Generate our server ID (the version is not part of he fingerprint)
680//
681 strcpy(iBuff, "=/");
682 kySID = XrdOucUtils::Ident(mySID, iBuff+2, sizeof(iBuff)-2,
683 iHost, iProg, iName, Port);
684 n = strlen(iBuff);
685 snprintf(iBuff+n, sizeof(iBuff)-n, "&ver=%s", XrdVERSION);
686
687 kySIDSZ = strlen(kySID);
688 monHost = strdup(iHost);
689
690// Ignore array bounds warning from gcc 12 triggered because the allocated
691// memory for the XrdXrootdMonMap is smaller than sizeof(XrdXrootdMonMap)
692#if defined(__GNUC__) && __GNUC__ >= 12
693#pragma GCC diagnostic push
694#pragma GCC diagnostic ignored "-Warray-bounds"
695#endif
696// Create identification record
697//
698 idLen = strlen(iBuff) + sizeof(XrdXrootdMonHeader) + sizeof(kXR_int32);
699 idRec = (char *)malloc(idLen+1);
700 mP = (XrdXrootdMonMap *)idRec;
701 fillHeader(&(mP->hdr), XROOTD_MON_MAPIDNT, idLen);
702 mP->hdr.pseq = 0;
703 mP->dictid = 0;
704 strcpy(mP->info, iBuff);
705#if defined(__GNUC__) && __GNUC__ >= 12
706#pragma GCC diagnostic pop
707#endif
708
709// Generate a CGI version of all the variations
710//
711 const char *Site (getenv("XRDSITE") ? getenv("XRDSITE") : "");
712 i = snprintf(iPuff, sizeof(iPuff), cgID0, Site);
713 SidCGI[0] = strdup(iPuff);
714 LidCGI[0] = strlen(iPuff);
715
716 n = sizeof(iPuff)-i; j = i;
717 i = snprintf(iPuff+j, n, cgID1, iHost);
718 SidCGI[1] = strdup(iPuff);
719 LidCGI[1] = strlen(iPuff);
720
721 n -= i; j += i;
722 i = snprintf(iPuff+j, n, cgID2, Port, iName);
723 SidCGI[2] = strdup(iPuff);
724 LidCGI[2] = strlen(iPuff);
725
726 n -= i; j += i;
727 snprintf(iPuff+j, n, cgID3, iProg, XrdVERSION);
728 SidCGI[3] = strdup(iPuff);
729 LidCGI[3] = strlen(iPuff);
730
731// Generate a JSON version of all the variations.
732//
733 n = snprintf(iPuff, sizeof(iPuff), jsID0, Site);
734 SidJSON[0] = strdup(iPuff);
735 LidJSON[0] = strlen(iPuff);
736
737 strcpy(iPuff+n-1, ",");
738 n = snprintf(iMuff, sizeof(iMuff), jsID1, iPuff, iHost);
739 SidJSON[1] = strdup(iMuff);
740 LidJSON[1] = strlen(iMuff);
741
742 strcpy(iMuff+n-1, ",");
743 n = snprintf(iPuff, sizeof(iPuff), jsID2, iMuff, Port, iName);
744 SidJSON[2] = strdup(iPuff);
745 LidJSON[2] = strlen(iPuff);
746
747 strcpy(iPuff+n-1, ",");
748 snprintf(iMuff, sizeof(iMuff), jsID3, iPuff, iProg, XrdVERSION);
749 SidJSON[3] = strdup(iMuff);
750 LidJSON[3] = strlen(iMuff);
751}
const kXR_char XROOTD_MON_MAPIDNT
char info[1024+256]
XrdXrootdMonHeader hdr
static char * Ident(long long &mySID, char *iBuff, int iBlen, const char *iHost, const char *iProg, const char *iName, int Port)

References XrdXrootdMonMap::dictid, eDest, XrdXrootdMonMap::hdr, XrdOucUtils::Ident(), XrdXrootdMonMap::info, XrdXrootdMonInfo::kySID, XrdXrootdMonInfo::kySIDSZ, XrdXrootdMonInfo::LidCGI, XrdXrootdMonInfo::LidJSON, XrdXrootdMonInfo::monHost, XrdXrootdMonInfo::mySID, XrdXrootdMonHeader::pseq, XrdXrootdMonInfo::Sched, XrdXrootdMonInfo::SidCGI, XrdXrootdMonInfo::SidJSON, and XROOTD_MON_MAPIDNT.

Here is the call graph for this function:

◆ ModeEnabled()

bool XrdXrootdMonitor::ModeEnabled ( int mode)
inlinestatic

Definition at line 150 of file XrdXrootdMonitor.hh.

151 {return ((monMode1|monMode2) & mode) != 0;}

◆ Open()

void XrdXrootdMonitor::Open ( kXR_unt32 dictid,
off_t fsize )

Definition at line 906 of file XrdXrootdMonitor.cc.

907{
908 XrdXrootdMonitorLock mLock(this);
909
910 if (lastWindow != currWindow) Mark();
911 else if (nextEnt == lastEnt) Flush();
912 h2nll(fsize, monBuff->info[nextEnt].arg0.val);
913 monBuff->info[nextEnt].arg0.id[0] = XROOTD_MON_OPEN;
914 monBuff->info[nextEnt].arg1.buflen = 0;
915 monBuff->info[nextEnt++].arg2.dictid = dictid;
916
917// Check if we need to duplicate this entry
918//
919 if (altMon && this != altMon) altMon->Dup(&monBuff->info[nextEnt-1]);
920}
const kXR_char XROOTD_MON_OPEN

References altMon, and XROOTD_MON_OPEN.

◆ Redirect() [1/2]

int XrdXrootdMonitor::Redirect ( )
inlinestatic

Definition at line 155 of file XrdXrootdMonitor.hh.

155{return monREDR;}

Referenced by XrdXrootdCallBack::sendError().

Here is the caller graph for this function:

◆ Redirect() [2/2]

int XrdXrootdMonitor::Redirect ( kXR_unt32 mID,
const char * hName,
int Port,
const char opC,
const char * Path )
static

Definition at line 926 of file XrdXrootdMonitor.cc.

928{
929 XrdXrootdMonRedir *mtP;
930 MonRdrBuff *mP = Fetch();
931 int n, slots, hLen, pLen, room;
932 char *dest;
933
934// Take care of the server's name which might actually be a path
935//
936 if (*hName == '/') {Path = hName; hName = ""; hLen = 0;}
937 else {const char *quest = index(hName, '?');
938 hLen = (quest ? quest - hName : strlen(hName));
939 if (hLen > 256) hLen = 256;
940 }
941
942// Take care of the path. Only the truncated length may be copied, as the
943// path can be longer than the slots that hold it. CopyText() then ends the
944// path with a null byte and null pads the rest of the slots.
945//
946 pLen = strlen(Path);
947 if (pLen > 1024) pLen = 1024;
948
949// Compute number of entries needed here
950//
951 n = (hLen + 1 + pLen + 1); // "<host>:<path>\0"
952 slots = n / sizeof(XrdXrootdMonRedir);
953 if (n % sizeof(XrdXrootdMonRedir)) slots++;
954 room = slots * sizeof(XrdXrootdMonRedir) - (hLen+1);
955
956// Obtain a lock on this buffer
957//
958 if (!mP) return 0;
959 mP->Mutex.Lock();
960
961// If we don't have enough slots, flush this buffer. Note that we account for
962// the ending timing mark here (an extra slot).
963//
964 if (mP->nextEnt + slots + 2 >= lastRnt) Flush(mP);
965
966// Check if we need a timing mark
967//
968 if (mP->lastTOD != rdrTOD)
969 {mP->lastTOD = rdrTOD;
970 setTMurk(mP->Buff, mP->nextEnt, mP->lastTOD);
971 mP->nextEnt++;
972 }
973
974// Fill out the buffer
975//
976 mtP = &(mP->Buff->info[mP->nextEnt]);
977 mtP->arg0.rdr.Type = XROOTD_MON_REDIRECT | opC;
978 mtP->arg0.rdr.Dent = static_cast<char>(slots);
979 mtP->arg0.rdr.Port = htons(static_cast<short>(Port));
980 mtP->arg1.dictid = mID;
981 dest = (char *)(mtP+1);
982 strncpy(dest, hName,hLen); dest += hLen; *dest++ = ':';
983 CopyText(dest, room, Path, pLen);
984
985// Adjust pointer and return
986//
987 mP->nextEnt = mP->nextEnt + (slots+1);
988 mP->Mutex.UnLock();
989 return 0;
990}
XrdOucString Path
union XrdXrootdMonRedir::@017044370107177241030156067342362323316131075335 arg0
union XrdXrootdMonRedir::@124330332126055120131203275034312305071227313005 arg1
const kXR_char XROOTD_MON_REDIRECT
#define setTMurk(TM_mb, TM_en, TM_tm)
static int CopyText(char *buff, int room, const char *text, int tLen)

References XrdXrootdMonRedir::arg0, XrdXrootdMonRedir::arg1, CopyText(), XrdXrootdMonBurr::info, XrdSysMutex::Lock(), Path, setTMurk, XrdSysMutex::UnLock(), and XROOTD_MON_REDIRECT.

Here is the call graph for this function:

◆ Send()

int XrdXrootdMonitor::Send ( int mmode,
void * buff,
int size,
bool setseq = true )
static

Definition at line 1228 of file XrdXrootdMonitor.cc.

1229{
1230#ifndef NODEBUG
1231 const char *TraceID = "Monitor";
1232#endif
1233 static XrdSysMutex sendMutex;
1234 static int seq1=0, seq2=0;
1235 XrdXrootdMonHeader *mHdr=0;
1236 int rc1, rc2;
1237
1238// If we are to set sequence numbers, recast the buffer. We are assured that
1239// the buffer always starts with the standard monitor header.
1240//
1241 if (setseq) mHdr = static_cast<XrdXrootdMonHeader*>(buff);
1242
1243 sendMutex.Lock();
1244 if (monMode & monMode1 && InetDest1)
1245 {if (mHdr) mHdr->pseq = (seq1++) & 0xff;
1246 rc1 = InetDest1->Send((char *)buff, blen);
1247 TRACE(DEBUG,blen <<" bytes sent to " <<Dest1 <<" rc=" <<rc1);
1248 }
1249 else rc1 = 0;
1250 if (monMode & monMode2 && InetDest2)
1251 {if (mHdr) mHdr->pseq = (seq2++) & 0xff;
1252 rc2 = InetDest2->Send((char *)buff, blen);
1253 TRACE(DEBUG,blen <<" bytes sent to " <<Dest2 <<" rc=" <<rc2);
1254 }
1255 else rc2 = 0;
1256 sendMutex.UnLock();
1257
1258 return (rc1 ? rc1 : rc2);
1259}
#define DEBUG(x)
#define TRACE(act, x)
Definition XrdTrace.hh:63

References DEBUG, XrdSysMutex::Lock(), XrdXrootdMonHeader::pseq, TRACE, and XrdSysMutex::UnLock().

Referenced by Ident().

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

◆ Tick()

time_t XrdXrootdMonitor::Tick ( )
static

Definition at line 997 of file XrdXrootdMonitor.cc.

998{
999 time_t Now = time(0);
1000 int nextFlush;
1001
1002// We can safely set the window as we are the only ones doing so and memory
1003// access is atomic as long as it sits within a cache line (which it does).
1004//
1005 currWindow = static_cast<kXR_int32>(Now);
1006 rdrTOD = htonl(currWindow);
1007 nextFlush = currWindow + autoFlush;
1008
1009// Check to see if we should flush the alternate monitor
1010//
1011 if (altMon && currWindow >= FlushTime)
1013 if (currWindow >= FlushTime)
1014 {if (altMon->nextEnt > 1) altMon->Flush();
1015 else FlushTime = nextFlush;
1016 }
1018 }
1019
1020// Now check to see if we need to flush redirect buffers
1021//
1022 if (monREDR)
1023 {int n = rdrNum;
1024 while(n--)
1025 {rdrMon[n].Mutex.Lock();
1026 if (rdrMon[n].nextEnt == 0) rdrMon[n].flushIt = nextFlush;
1027 else if (rdrMon[n].flushIt <= currWindow) Flush(&rdrMon[n]);
1028 rdrMon[n].Mutex.UnLock();
1029 }
1030 }
1031
1032// All done. Stop the clock if there is no reason for it to be running. The
1033// clock always runs if we are monitoring redirects or all clients. Otherwise,
1034// the clock only runs if we have a one or more client-specific monitors.
1035//
1036 if (!monREDR && isEnabled < 0)
1037 {windowMutex.Lock();
1038 if (!numMonitor) Now = 0;
1039 windowMutex.UnLock();
1040 }
1041 return Now;
1042}

References altMon, XrdXrootdMonitorLock::Lock(), and XrdXrootdMonitorLock::UnLock().

Referenced by XrdXrootdMonitor_Tick::DoIt().

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

◆ User

friend class User
friend

Definition at line 84 of file XrdXrootdMonitor.hh.

◆ XrdXrootdMonFile

friend class XrdXrootdMonFile
friend

Definition at line 85 of file XrdXrootdMonitor.hh.

References XrdXrootdMonFile.

Referenced by XrdXrootdMonFile.

Member Data Documentation

◆ altMon

XrdXrootdMonitor * XrdXrootdMonitor::altMon = 0
static

◆ maxDgram

int XrdXrootdMonitor::maxDgram = 65507
staticconstexpr

The largest UDP payload over IPv4: 65535 bytes less the 20-byte IP header and the 8-byte UDP header. A larger datagram cannot be sent.

Definition at line 256 of file XrdXrootdMonitor.hh.

Referenced by XrdXrootdMonFile::Defaults(), and Defaults().

◆ rdrMax

const int XrdXrootdMonitor::rdrMax = 8
static

Definition at line 251 of file XrdXrootdMonitor.hh.

Referenced by Defaults().


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