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 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 XrdXrootdMonitoraltMon = 0
 
static const int rdrMax = 8
 

Friends

class User
 
class XrdXrootdMonFile
 

Detailed Description

Definition at line 79 of file XrdXrootdMonitor.hh.

Constructor & Destructor Documentation

◆ XrdXrootdMonitor()

XrdXrootdMonitor::XrdXrootdMonitor ( )

Definition at line 366 of file XrdXrootdMonitor.cc.

367{
368 kXR_int32 localWindow;
369
370// Initialize last window to force a mark as well as the local window
371//
372 lastWindow = 0;
373 localWindow = currWindow;
374
375// Allocate a monitor buffer
376//
377 if (posix_memalign((void **)&monBuff, getpagesize(), monBlen))
378 eDest->Emsg("Monitor", "Unable to allocate monitor buffer.");
379 else {nextEnt = 1;
380 setTMark(monBuff, 0, localWindow);
381 }
382}
int kXR_int32
Definition XPtypes.hh:89
static XrdSysError eDest(0,"crypto_")
#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 88 of file XrdXrootdMonitor.hh.

91 {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 93 of file XrdXrootdMonitor.hh.

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

References XrdXrootdMonTrace::arg0, XrdXrootdMonTrace::arg1, XrdXrootdMonTrace::arg2, and XrdXrootdMonBuff::info.

◆ Add_wr()

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

Definition at line 108 of file XrdXrootdMonitor.hh.

111 {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 398 of file XrdXrootdMonitor.cc.

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

References altMon, XrdXrootdMonTrace::arg0, XrdXrootdMonBuff::info, and XROOTD_MON_APPID.

◆ Close()

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

Definition at line 450 of file XrdXrootdMonitor.cc.

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

References altMon, XrdXrootdMonTrace::arg0, XrdXrootdMonTrace::arg1, XrdXrootdMonTrace::arg2, XrdXrootdMonBuff::info, and XROOTD_MON_CLOSE.

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

+ 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 478 of file XrdXrootdMonitor.cc.

479{
480 int mmode;
481
482// If there are no destination then only g-stream events may be enabled.
483// Otherwise, sort out the destinations relative to modes.
484//
485 if (!dest1 && !dest2) {isEnabled = 0; return;}
486 if (!dest1) {dest1 = dest2; dest2 = 0; mode1 |= mode2; mode2 = 0;}
487
488// Set the default destinations (caller supplied strdup'd strings)
489//
490 if (Dest1) free(Dest1);
491 Dest1 = dest1; monMode1 = mode1;
492 if (Dest2) free(Dest2);
493 Dest2 = dest2; monMode2 = mode2;
494
495// Set overall monitor mode
496//
497 mmode = mode1 | mode2;
498 monACTIVE = (mmode ? 1 : 0);
499 isEnabled = (mmode & XROOTD_MON_ALL ? 1 :-1);
500 monIO = (mmode & XROOTD_MON_IO ? 1 : 0);
501 monIO = (mmode & XROOTD_MON_IOV ? 2 : monIO);
502 monINFO = (mmode & XROOTD_MON_INFO ? 1 : 0);
503 monFILE = (mmode & XROOTD_MON_FILE ? 1 : 0) | monIO;
504 monREDR = (mmode & XROOTD_MON_REDR ? 1 : 0);
505 monUSER = (mmode & XROOTD_MON_USER ? 1 : 0);
506 monAUTH = (mmode & XROOTD_MON_AUTH ? 1 : 0);
507 monFSTAT = (mmode & XROOTD_MON_FSTA && monFSTAT ? 1 : 0);
508
509// Compute whether or not we need the clock running
510//
511 if (monREDR || (isEnabled > 0 && (monIO || monFILE))) monCLOCK = 1;
512
513// Check where user information should go
514//
515 if (((mode1 & XROOTD_MON_IO) && (mode1 & XROOTD_MON_USER))
516 || ((mode2 & XROOTD_MON_IO) && (mode2 & XROOTD_MON_USER)))
517 {if ((!(mode1 & XROOTD_MON_IO) && (mode1 & XROOTD_MON_USER))
518 || (!(mode2 & XROOTD_MON_IO) && (mode2 & XROOTD_MON_USER))) monUSER = 3;
519 else monUSER = 2;
520 }
521
522// If we are monitoring redirections then set an envar saying how often idents
523// should be sent (this also tips off other layers to handle such monitoring)
524//
525 if (monREDR) XrdOucEnv::Export("XRDMONRDR", monIdent);
526}
#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 530 of file XrdXrootdMonitor.cc.

533{
534
535// Set default window size and flush time
536//
537 sizeWindow = (wsz <= 0 ? 60 : wsz);
538 autoFlush = (flush <= 0 ? 600 : flush);
539 autoFlash = (flash <= 0 ? 0 : flash);
540 monIdent = idt;
541 rdrNum = (rnm <= 0 || rnm > rdrMax ? 3 : rnm);
542 rdrWin = (sizeWindow > 16777215 ? 16777215 : sizeWindow);
543 rdrWin = htonl(rdrWin);
544
545// Set the fstat defaults
546//
547 XrdXrootdMonFile::Defaults(fsint, fsopt, fsion, fbsz);
548 monFSTAT = fsint != 0;
549
550// Set default monitor buffer size
551//
552 if (msz <= 0) msz = 16384;
553 else if (msz < 1024) msz = 1024;
554 else msz = msz/sizeof(XrdXrootdMonTrace)*sizeof(XrdXrootdMonTrace);
555 lastEnt = (msz-sizeof(XrdXrootdMonHeader))/sizeof(XrdXrootdMonTrace);
556 monBlen = (lastEnt*sizeof(XrdXrootdMonTrace))+sizeof(XrdXrootdMonHeader);
557 lastEnt--;
558
559// Set default monitor redirect buffer size
560//
561 if (rsz <= 0) rsz = 32768;
562 else if (rsz < 2048) rsz = 2048;
563 lastRnt = (rsz-(sizeof(XrdXrootdMonHeader) + 16))/sizeof(XrdXrootdMonRedir);
564 monRlen = (lastRnt*sizeof(XrdXrootdMonRedir))+sizeof(XrdXrootdMonHeader)+16;
565 lastRnt--;
566}
static void Defaults(int intv, int opts, int iocnt, int fbsz)
static const int rdrMax

References XrdXrootdMonFile::Defaults(), 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 572 of file XrdXrootdMonitor.cc.

573{
574 XrdXrootdMonitorLock mLock(this);
575
576// Check if this should not be included in the io trace
577//
578 if (this != altMon && monUSER == 1 && altMon)
579 {altMon->Disc(dictid, csec); return;}
580
581// Fill out the monitor record (let compiler cast the data correctly)
582//
583 if (lastWindow != currWindow) Mark();
584 else if (nextEnt == lastEnt) Flush();
585 monBuff->info[nextEnt].arg0.rTot[0] = 0;
586 monBuff->info[nextEnt].arg0.id[0] = XROOTD_MON_DISC;
587 monBuff->info[nextEnt].arg0.id[1] = Flags;
588 monBuff->info[nextEnt].arg1.wTot = htonl(csec);
589 monBuff->info[nextEnt++].arg2.dictid = dictid;
590
591// Check if we need to duplicate this entry
592//
593 if (altMon && this != altMon && monUSER == 3)
594 altMon->Dup(&monBuff->info[nextEnt-1]);
595}
const kXR_char XROOTD_MON_DISC
void Disc(kXR_unt32 dictid, int csec, char Flags=0)

References altMon, XrdXrootdMonTrace::arg0, XrdXrootdMonTrace::arg1, XrdXrootdMonTrace::arg2, Disc(), XrdXrootdMonBuff::info, 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()

static int XrdXrootdMonitor::Flushing ( )
inlinestatic

Definition at line 124 of file XrdXrootdMonitor.hh.

124{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 816 of file XrdXrootdMonitor.cc.

817{
818 static XrdSysMutex seqMutex;
819 static unsigned int monSeqID = 1;
820 unsigned int mySeqID;
821
822// Assign a unique ID for this entry
823//
824 seqMutex.Lock();
825 mySeqID = monSeqID++;
827
828// Return the ID
829//
830 if (hbo) return mySeqID;
831 return htonl(mySeqID);
832}

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()

static void XrdXrootdMonitor::Ident ( )
inlinestatic

Definition at line 128 of file XrdXrootdMonitor.hh.

128{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 732 of file XrdXrootdMonitor.cc.

733{
734 static XrdXrootdMonitor_Ident MonIdent(monIdent, isEnabled);
735 int i, Now = time(0);
736 bool aOK;
737
738// Setup the primary destination
739//
740 if (Dest1)
741 {InetDest1 = new XrdNetMsg(eDest, Dest1, &aOK);
742 if (!aOK)
743 {eDest->Emsg("Monitor", "Unable to setup primary monitor collector.");
744 return 0;
745 }
746 }
747
748// Setup the secondary destination
749//
750 if (Dest2)
751 {InetDest2 = new XrdNetMsg(eDest, Dest2, &aOK);
752 if (!aOK)
753 {eDest->Emsg("Monitor","Unable to setup secondary monitor collector.");
754 return 0;
755 }
756 }
757
758// Now schedule the first identification record
759//
760 if (Sched && monIdent >= 0) Sched->Schedule((XrdJob *)&MonIdent);
761
762// There is nothing more to do unless we have been enabled via Defaults()
763//
764 if (!isEnabled) return 1;
765
766// If there is a destination that is only collecting file events, then
767// allocate a global monitor object but don't start the timer just yet.
768//
769 if ((monMode1 && !(monMode1 & XROOTD_MON_IO))
770 || (monMode2 && !(monMode2 & XROOTD_MON_IO)))
771 if (!(altMon = new XrdXrootdMonitor()) || !altMon->monBuff)
772 {if (altMon) {delete altMon; altMon = 0;}
773 eDest->Emsg("Monitor","allocate monitor; insufficient storage.");
774 return 0;
775 }
776
777// Turn on the monitoring clock if we need it running all the time
778//
779 if (monCLOCK) startClock();
780
781// If we are monitoring file stats then start that up
782//
783 if (!Sched || !monFSTAT) monFSTAT = 0;
784 else if (!XrdXrootdMonFile::Init()) return 0;
785
786// If we are not monitoring redirections, we are done!
787//
788 if (!monREDR) return 1;
789
790// Allocate as many redirection monitors as requested
791//
792 for (i = 0; i < rdrNum; i++)
793 {if (posix_memalign((void **)&rdrMon[i].Buff, getpagesize(),monRlen))
794 {eDest->Emsg("Monitor", "Unable to allocate monitor rdr buffer.");
795 return 0;
796 }
797 rdrMon[i].Buff->sID = mySID;
798 rdrMon[i].Buff->sXX[0] = XROOTD_MON_REDSID;
799 rdrMon[i].Next = (i ? &rdrMon[i-1] : &rdrMon[0]);
800 rdrMon[i].nextEnt = 0;
801 rdrMon[i].flushIt = Now + autoFlush;
802 rdrMon[i].lastTOD = 0;
803 }
804 rdrMon[0].Next = &rdrMon[i-1];
805 rdrMP = &rdrMon[0];
806
807// All done
808//
809 return 1;
810}
const kXR_char XROOTD_MON_REDSID
void Schedule(XrdJob *jp)
XrdScheduler * Sched

References 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 633 of file XrdXrootdMonitor.cc.

636{
637 const char *cgID0 = "&site=%s";
638 const char *cgID1 = "&host=%s";
639 const char *cgID2 = "&port=%d&inst=%s";
640 const char *cgID3 = "&pgm=%s&ver=%s";
641
642 const char *jsID0 = "\"src\":{\"site\":\"%s\"}";
643 const char *jsID1 = "%s\"host\":\"%s\"}";
644 const char *jsID2 = "%s\"port\":%d,\"inst\":\"%s\"}";
645 const char *jsID3 = "%s\"pgm\":\"%s\",\"ver\":\"%s\"}";
646
647 XrdXrootdMonMap *mP;
648 char iBuff[1024], iMuff[2048], iPuff[1024];
649 int n, i, j;
650
651// Set static variables
652//
653 Sched = sp;
654 eDest = errp;
655
656// Generate our server ID (the version is not part of he fingerprint)
657//
658 strcpy(iBuff, "=/");
659 kySID = XrdOucUtils::Ident(mySID, iBuff+2, sizeof(iBuff)-2,
660 iHost, iProg, iName, Port);
661 n = strlen(iBuff);
662 snprintf(iBuff+n, sizeof(iBuff)-n, "&ver=%s", XrdVERSION);
663
664 kySIDSZ = strlen(kySID);
665 monHost = strdup(iHost);
666
667// Ignore array bounds warning from gcc 12 triggered because the allocated
668// memory for the XrdXrootdMonMap is smaller than sizeof(XrdXrootdMonMap)
669#if defined(__GNUC__) && __GNUC__ >= 12
670#pragma GCC diagnostic push
671#pragma GCC diagnostic ignored "-Warray-bounds"
672#endif
673// Create identification record
674//
675 idLen = strlen(iBuff) + sizeof(XrdXrootdMonHeader) + sizeof(kXR_int32);
676 idRec = (char *)malloc(idLen+1);
677 mP = (XrdXrootdMonMap *)idRec;
678 fillHeader(&(mP->hdr), XROOTD_MON_MAPIDNT, idLen);
679 mP->hdr.pseq = 0;
680 mP->dictid = 0;
681 strcpy(mP->info, iBuff);
682#if defined(__GNUC__) && __GNUC__ >= 12
683#pragma GCC diagnostic pop
684#endif
685
686// Generate a CGI version of all the variations
687//
688 const char *Site (getenv("XRDSITE") ? getenv("XRDSITE") : "");
689 i = snprintf(iPuff, sizeof(iPuff), cgID0, Site);
690 SidCGI[0] = strdup(iPuff);
691 LidCGI[0] = strlen(iPuff);
692
693 n = sizeof(iPuff)-i; j = i;
694 i = snprintf(iPuff+j, n, cgID1, iHost);
695 SidCGI[1] = strdup(iPuff);
696 LidCGI[1] = strlen(iPuff);
697
698 n -= i; j += i;
699 i = snprintf(iPuff+j, n, cgID2, Port, iName);
700 SidCGI[2] = strdup(iPuff);
701 LidCGI[2] = strlen(iPuff);
702
703 n -= i; j += i;
704 snprintf(iPuff+j, n, cgID3, iProg, XrdVERSION);
705 SidCGI[3] = strdup(iPuff);
706 LidCGI[3] = strlen(iPuff);
707
708// Generate a JSON version of all the variations.
709//
710 n = snprintf(iPuff, sizeof(iPuff), jsID0, Site);
711 SidJSON[0] = strdup(iPuff);
712 LidJSON[0] = strlen(iPuff);
713
714 strcpy(iPuff+n-1, ",");
715 n = snprintf(iMuff, sizeof(iMuff), jsID1, iPuff, iHost);
716 SidJSON[1] = strdup(iMuff);
717 LidJSON[1] = strlen(iMuff);
718
719 strcpy(iMuff+n-1, ",");
720 n = snprintf(iPuff, sizeof(iPuff), jsID2, iMuff, Port, iName);
721 SidJSON[2] = strdup(iPuff);
722 LidJSON[2] = strlen(iPuff);
723
724 strcpy(iPuff+n-1, ",");
725 snprintf(iMuff, sizeof(iMuff), jsID3, iPuff, iProg, XrdVERSION);
726 SidJSON[3] = strdup(iMuff);
727 LidJSON[3] = strlen(iMuff);
728}
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()

static bool XrdXrootdMonitor::ModeEnabled ( int mode)
inlinestatic

Definition at line 136 of file XrdXrootdMonitor.hh.

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

◆ Open()

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

Definition at line 878 of file XrdXrootdMonitor.cc.

879{
880 XrdXrootdMonitorLock mLock(this);
881
882 if (lastWindow != currWindow) Mark();
883 else if (nextEnt == lastEnt) Flush();
884 h2nll(fsize, monBuff->info[nextEnt].arg0.val);
885 monBuff->info[nextEnt].arg0.id[0] = XROOTD_MON_OPEN;
886 monBuff->info[nextEnt].arg1.buflen = 0;
887 monBuff->info[nextEnt++].arg2.dictid = dictid;
888
889// Check if we need to duplicate this entry
890//
891 if (altMon && this != altMon) altMon->Dup(&monBuff->info[nextEnt-1]);
892}
const kXR_char XROOTD_MON_OPEN

References altMon, XrdXrootdMonTrace::arg0, XrdXrootdMonTrace::arg1, XrdXrootdMonTrace::arg2, XrdXrootdMonBuff::info, and XROOTD_MON_OPEN.

◆ Redirect() [1/2]

static int XrdXrootdMonitor::Redirect ( )
inlinestatic

Definition at line 141 of file XrdXrootdMonitor.hh.

141{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 898 of file XrdXrootdMonitor.cc.

900{
902 MonRdrBuff *mP = Fetch();
903 int n, slots, hLen, pLen;
904 char *dest;
905
906// Take care of the server's name which might actually be a path
907//
908 if (*hName == '/') {Path = hName; hName = ""; hLen = 0;}
909 else {const char *quest = index(hName, '?');
910 hLen = (quest ? quest - hName : strlen(hName));
911 if (hLen > 256) hLen = 256;
912 }
913
914// Take care of the path
915//
916 pLen = strlen(Path);
917 if (pLen > 1024) pLen = 1024;
918
919// Compute number of entries needed here
920//
921 n = (hLen + 1 + pLen + 1); // "<host>:<path>\0"
922 slots = n / sizeof(XrdXrootdMonRedir);
923 if (n % sizeof(XrdXrootdMonRedir)) slots++;
924 pLen = slots * sizeof(XrdXrootdMonRedir) - (hLen+1);
925
926// Obtain a lock on this buffer
927//
928 if (!mP) return 0;
929 mP->Mutex.Lock();
930
931// If we don't have enough slots, flush this buffer. Note that we account for
932// the ending timing mark here (an extra slot).
933//
934 if (mP->nextEnt + slots + 2 >= lastRnt) Flush(mP);
935
936// Check if we need a timing mark
937//
938 if (mP->lastTOD != rdrTOD)
939 {mP->lastTOD = rdrTOD;
940 setTMurk(mP->Buff, mP->nextEnt, mP->lastTOD);
941 mP->nextEnt++;
942 }
943
944// Fill out the buffer
945//
946 mtP = &(mP->Buff->info[mP->nextEnt]);
947 mtP->arg0.rdr.Type = XROOTD_MON_REDIRECT | opC;
948 mtP->arg0.rdr.Dent = static_cast<char>(slots);
949 mtP->arg0.rdr.Port = htons(static_cast<short>(Port));
950 mtP->arg1.dictid = mID;
951 dest = (char *)(mtP+1);
952 strncpy(dest, hName,hLen); dest += hLen; *dest++ = ':';
953 strncpy(dest, Path, pLen);
954
955// Adjust pointer and return
956//
957 mP->nextEnt = mP->nextEnt + (slots+1);
958 mP->Mutex.UnLock();
959 return 0;
960}
XrdOucString Path
union XrdXrootdMonRedir::@174 arg0
union XrdXrootdMonRedir::@175 arg1
const kXR_char XROOTD_MON_REDIRECT
#define setTMurk(TM_mb, TM_en, TM_tm)

References XrdXrootdMonRedir::arg0, XrdXrootdMonRedir::arg1, 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 1198 of file XrdXrootdMonitor.cc.

1199{
1200#ifndef NODEBUG
1201 const char *TraceID = "Monitor";
1202#endif
1203 static XrdSysMutex sendMutex;
1204 static int seq1=0, seq2=0;
1205 XrdXrootdMonHeader *mHdr=0;
1206 int rc1, rc2;
1207
1208// If we are to set sequence numbers, recast the buffer. We are assured that
1209// the buffer always starts with the standard monitor header.
1210//
1211 if (setseq) mHdr = static_cast<XrdXrootdMonHeader*>(buff);
1212
1213 sendMutex.Lock();
1214 if (monMode & monMode1 && InetDest1)
1215 {if (mHdr) mHdr->pseq = (seq1++) & 0xff;
1216 rc1 = InetDest1->Send((char *)buff, blen);
1217 TRACE(DEBUG,blen <<" bytes sent to " <<Dest1 <<" rc=" <<rc1);
1218 }
1219 else rc1 = 0;
1220 if (monMode & monMode2 && InetDest2)
1221 {if (mHdr) mHdr->pseq = (seq2++) & 0xff;
1222 rc2 = InetDest2->Send((char *)buff, blen);
1223 TRACE(DEBUG,blen <<" bytes sent to " <<Dest2 <<" rc=" <<rc2);
1224 }
1225 else rc2 = 0;
1226 sendMutex.UnLock();
1227
1228 return (rc1 ? rc1 : rc2);
1229}
#define DEBUG(x)
#define TRACE(act, x)
Definition XrdTrace.hh:63
int Send(const char *buff, int blen=0, const char *dest=0, int tmo=-1)
Definition XrdNetMsg.cc:70

References DEBUG, XrdSysMutex::Lock(), XrdXrootdMonHeader::pseq, XrdNetMsg::Send(), 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 967 of file XrdXrootdMonitor.cc.

968{
969 time_t Now = time(0);
970 int nextFlush;
971
972// We can safely set the window as we are the only ones doing so and memory
973// access is atomic as long as it sits within a cache line (which it does).
974//
975 currWindow = static_cast<kXR_int32>(Now);
976 rdrTOD = htonl(currWindow);
977 nextFlush = currWindow + autoFlush;
978
979// Check to see if we should flush the alternate monitor
980//
981 if (altMon && currWindow >= FlushTime)
983 if (currWindow >= FlushTime)
984 {if (altMon->nextEnt > 1) altMon->Flush();
985 else FlushTime = nextFlush;
986 }
988 }
989
990// Now check to see if we need to flush redirect buffers
991//
992 if (monREDR)
993 {int n = rdrNum;
994 while(n--)
995 {rdrMon[n].Mutex.Lock();
996 if (rdrMon[n].nextEnt == 0) rdrMon[n].flushIt = nextFlush;
997 else if (rdrMon[n].flushIt <= currWindow) Flush(&rdrMon[n]);
998 rdrMon[n].Mutex.UnLock();
999 }
1000 }
1001
1002// All done. Stop the clock if there is no reason for it to be running. The
1003// clock always runs if we are monitoring redirects or all clients. Otherwise,
1004// the clock only runs if we have a one or more client-specific monitors.
1005//
1006 if (!monREDR && isEnabled < 0)
1007 {windowMutex.Lock();
1008 if (!numMonitor) Now = 0;
1009 windowMutex.UnLock();
1010 }
1011 return Now;
1012}

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

Referenced by XrdXrootdMonitor_Tick::DoIt().

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

Friends And Related Symbol Documentation

◆ User

friend class User
friend

Definition at line 83 of file XrdXrootdMonitor.hh.

◆ XrdXrootdMonFile

friend class XrdXrootdMonFile
friend

Definition at line 84 of file XrdXrootdMonitor.hh.

Member Data Documentation

◆ altMon

XrdXrootdMonitor * XrdXrootdMonitor::altMon = 0
static

◆ rdrMax

const int XrdXrootdMonitor::rdrMax = 8
static

Definition at line 237 of file XrdXrootdMonitor.hh.

Referenced by Defaults().


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