XRootD
XrdFrmMonitor Class Reference

#include <XrdFrmMonitor.hh>

+ Collaboration diagram for XrdFrmMonitor:

Public Member Functions

 XrdFrmMonitor ()
 
 ~XrdFrmMonitor ()
 

Static Public Member Functions

static void Defaults (char *dest1, int m1, char *dest2, int m2, int iTime)
 
static void Ident ()
 
static int Init (const char *iHost, const char *iProg, const char *iName)
 
static kXR_unt32 Map (char code, const char *uname, const char *path)
 

Static Public Attributes

static char monMIGR = 0
 
static char monPURGE = 0
 
static char monSTAGE = 0
 

Detailed Description

Definition at line 47 of file XrdFrmMonitor.hh.

Constructor & Destructor Documentation

◆ XrdFrmMonitor()

XrdFrmMonitor::XrdFrmMonitor ( )

◆ ~XrdFrmMonitor()

XrdFrmMonitor::~XrdFrmMonitor ( )

Member Function Documentation

◆ Defaults()

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

Definition at line 84 of file XrdFrmMonitor.cc.

86 {
87 
88 // Make sure if we have a proper destinations and modes
89 //
90  if (dest1 && !mode1) {free(dest1); dest1 = 0; mode1 = 0;}
91  if (dest2 && !mode2) {free(dest2); dest2 = 0; mode2 = 0;}
92 
93 // Propogate the destinations
94 //
95  if (!dest1)
96  {mode1 = (dest1 = dest2) ? mode2 : 0;
97  dest2 = 0; mode2 = 0;
98  }
99 
100 // Set the default destinations (caller supplied strdup'd strings)
101 //
102  if (Dest1) free(Dest1);
103  Dest1 = dest1; monMode1 = mode1;
104  if (Dest2) free(Dest2);
105  Dest2 = dest2; monMode2 = mode2;
106 
107 // Set overall monitor mode
108 //
109  monMIGR = ((mode1 | mode2) & XROOTD_MON_MIGR ? 1 : 0);
110  monPURGE = ((mode1 | mode2) & XROOTD_MON_PURGE ? 1 : 0);
111  monSTAGE = ((mode1 | mode2) & XROOTD_MON_STAGE ? 1 : 0);
112 
113 // Do final check
114 //
115  isEnabled = (Dest1 == 0 && Dest2 == 0 ? 0 : 1);
116  idTime = iTime;
117 }
#define XROOTD_MON_PURGE
#define XROOTD_MON_MIGR
#define XROOTD_MON_STAGE
static char monPURGE
static char monMIGR
static char monSTAGE

References XROOTD_MON_MIGR, XROOTD_MON_PURGE, and XROOTD_MON_STAGE.

◆ Ident()

void XrdFrmMonitor::Ident ( )
static

Definition at line 123 of file XrdFrmMonitor.cc.

124 {
125 do{Send(-1, idRec, idLen);
126  XrdSysTimer::Snooze(idTime);
127  } while(1);
128 }
static void Snooze(int seconds)
Definition: XrdSysTimer.cc:168

References XrdSys::Send(), and XrdSysTimer::Snooze().

Referenced by XrdFrmMonitorID().

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

◆ Init()

int XrdFrmMonitor::Init ( const char *  iHost,
const char *  iProg,
const char *  iName 
)
static

Definition at line 134 of file XrdFrmMonitor.cc.

135 {
136  XrdXrootdMonMap *mP;
137  long long mySid;
138  const char *etext = 0;
139  char iBuff[1024];
140  bool aOK;
141 
142 // Generate our server ID
143 //
144  sidName = XrdOucUtils::Ident(mySid, iBuff, sizeof(iBuff), iHost, iProg,
145  (iName ? iName : "anon"), 0);
146  sidSize = strlen(sidName);
147  startTime = htonl(time(0));
148 
149 // There is nothing to do unless we have been enabled via Defaults()
150 //
151  if (!isEnabled) return 1;
152 
153 // Ignore array bounds warning from gcc 12 triggered because the allocated
154 // memory for the XrdXrootdMonMap is smaller than sizeof(XrdXrootdMonMap)
155 #if defined(__GNUC__) && __GNUC__ >= 12
156 #pragma GCC diagnostic push
157 #pragma GCC diagnostic ignored "-Warray-bounds"
158 #endif
159 // Create identification record
160 //
161  idLen = strlen(iBuff) + sizeof(XrdXrootdMonHeader) + sizeof(kXR_int32);
162  idRec = (char *)malloc(idLen+1);
163  mP = (XrdXrootdMonMap *)idRec;
164  fillHeader(&(mP->hdr), XROOTD_MON_MAPIDNT, idLen);
165  mP->hdr.pseq = 0;
166  mP->dictid = 0;
167  strcpy(mP->info, iBuff);
168 #if defined(__GNUC__) && __GNUC__ >= 12
169 #pragma GCC diagnostic pop
170 #endif
171 
172 // Setup the primary destination
173 //
174  InetDest1 = new XrdNetMsg(&Say, Dest1, &aOK);
175  if (!aOK)
176  {Say.Emsg("Monitor", "setup monitor collector;", etext);
177  return 0;
178  }
179 
180 // Do the same for the secondary destination
181 //
182  if (Dest2)
183  {InetDest2 = new XrdNetMsg(&Say, Dest2, &aOK);
184  if (!aOK)
185  {Say.Emsg("Monitor", "setup monitor collector;", etext);
186  return 0;
187  }
188  }
189 
190 // Check if we will be producing identification records
191 //
192  if (idTime)
193  {pthread_t tid;
194  int retc;
195  if ((retc = XrdSysThread::Run(&tid,XrdFrmMonitorID,0,0,"mon ident")))
196  {Say.Emsg("Init", retc, "create monitor ident thread"); return 0;}
197  }
198 
199 // All done
200 //
201  return 1;
202 }
int kXR_int32
Definition: XPtypes.hh:89
void * XrdFrmMonitorID(void *parg)
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)
Definition: XrdOucUtils.cc:702
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
XrdSysError Say

References XrdXrootdMonMap::dictid, XrdSysError::Emsg(), XrdXrootdMonMap::hdr, XrdOucUtils::Ident(), XrdXrootdMonMap::info, XrdXrootdMonHeader::pseq, XrdSysThread::Run(), XrdFrc::Say, XrdXrootdMonInfo::startTime, XrdFrmMonitorID(), and XROOTD_MON_MAPIDNT.

+ Here is the call graph for this function:

◆ Map()

kXR_unt32 XrdFrmMonitor::Map ( char  code,
const char *  uname,
const char *  path 
)
static

Definition at line 208 of file XrdFrmMonitor.cc.

209 {
210  XrdXrootdMonMap map;
211  const char *colonP, *atP;
212  char uBuff[1024];
213  int size, montype;
214 
215 // Decode the user name as a.b:c@d
216 //
217  if ((colonP = index(uname, ':')) && (atP = index(colonP+1, '@')))
218  {int n = colonP - uname + 1;
219  strncpy(uBuff, uname, n);
220  strcpy(uBuff+n, sidName);
221  strcpy(uBuff+n+sidSize, atP);
222  } else strcpy(uBuff, uname);
223 
224 // Copy in the username and path the dictid is always zero for us.
225 //
226  map.dictid = 0;
227  strcpy(map.info, uBuff);
228  size = strlen(uBuff);
229  if (path)
230  {*(map.info+size) = '\n';
231  strlcpy(map.info+size+1, path, sizeof(map.info)-size-1);
232  size = size + strlen(path) + 1;
233  }
234 
235 // Route the packet to all destinations that need them
236 //
237  if (code == XROOTD_MON_MAPSTAG){montype = XROOTD_MON_STAGE;
238  code = XROOTD_MON_MAPXFER;
239  }
240  else if (code == XROOTD_MON_MAPMIGR){montype = XROOTD_MON_MIGR;
241  code = XROOTD_MON_MAPXFER;
242  }
243  else if (code == XROOTD_MON_MAPPURG) montype = XROOTD_MON_PURGE;
244  else montype = XROOTD_MON_INFO;
245 
246 // Fill in the header and route the packet
247 //
248  size = sizeof(XrdXrootdMonHeader)+sizeof(kXR_int32)+size;
249  fillHeader(&map.hdr, code, size);
250 // std::cerr <<"Mon send "<<code <<": " <<map.info <<std::endl;
251  Send(montype, (void *)&map, size);
252 
253 // Return the dictionary id
254 //
255  return map.dictid;
256 }
#define XROOTD_MON_INFO
size_t strlcpy(char *dst, const char *src, size_t sz)
const kXR_char XROOTD_MON_MAPXFER
const kXR_char XROOTD_MON_MAPMIGR
const kXR_char XROOTD_MON_MAPSTAG
const kXR_char XROOTD_MON_MAPPURG

References XrdXrootdMonMap::dictid, XrdXrootdMonMap::hdr, XrdXrootdMonMap::info, XrdSys::Send(), strlcpy(), XROOTD_MON_INFO, XROOTD_MON_MAPMIGR, XROOTD_MON_MAPPURG, XROOTD_MON_MAPSTAG, XROOTD_MON_MAPXFER, XROOTD_MON_MIGR, XROOTD_MON_PURGE, and XROOTD_MON_STAGE.

+ Here is the call graph for this function:

Member Data Documentation

◆ monMIGR

char XrdFrmMonitor::monMIGR = 0
static

Definition at line 61 of file XrdFrmMonitor.hh.

◆ monPURGE

char XrdFrmMonitor::monPURGE = 0
static

Definition at line 62 of file XrdFrmMonitor.hh.

◆ monSTAGE

char XrdFrmMonitor::monSTAGE = 0
static

Definition at line 63 of file XrdFrmMonitor.hh.


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