Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:57

0001 #ifndef __XRDXROOTDMONDATA__
0002 #define __XRDXROOTDMONDATA__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                   X r d X r o o t d M o n D a t a . h h                    */
0006 /*                                                                            */
0007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 #include "XProtocol/XPtypes.hh"
0034 
0035 /******************************************************************************/
0036 /*                    P a c k e t   D e f i n i t i o n s                     */
0037 /******************************************************************************/
0038   
0039 struct XrdXrootdMonHeader
0040        {kXR_char   code;         // '='|'d'|'f'|'i'|'p'|'r'|'t'|'u'|'x'
0041         kXR_char   pseq;         // packet sequence
0042         kXR_unt16  plen;         // packet length
0043         kXR_int32  stod;         // Unix time at Server Start
0044        };
0045 
0046 struct XrdXrootdMonTrace
0047        {union {kXR_int64  val;
0048                kXR_char   id[8];
0049                kXR_unt16  sVal[4];
0050                kXR_unt32  rTot[2]; } arg0;
0051         union {kXR_int32  buflen;
0052                kXR_int32  Window;
0053                kXR_unt32  wTot;    } arg1;
0054         union {kXR_unt32  dictid;
0055                kXR_int32  Window;  } arg2;
0056        };
0057 
0058 struct XrdXrootdMonBuff
0059        {XrdXrootdMonHeader hdr;
0060         XrdXrootdMonTrace  info[sizeof(XrdXrootdMonTrace)]; //This is really [n]
0061        };
0062 
0063 struct XrdXrootdMonRedir
0064       {union   {kXR_int32 Window;
0065        struct  {kXR_char  Type;
0066                 kXR_char  Dent;
0067                 kXR_int16 Port;
0068                }          rdr;     } arg0;
0069        union   {kXR_unt32 dictid;
0070                 kXR_int32 Window;  } arg1;
0071       };
0072 
0073 struct XrdXrootdMonBurr
0074        {XrdXrootdMonHeader hdr;
0075         union {kXR_int64   sID;
0076                kXR_char    sXX[8]; };
0077         XrdXrootdMonRedir  info[sizeof(XrdXrootdMonRedir)]; //This is really [n]
0078        };
0079 
0080 struct XrdXrootdMonGS
0081       {XrdXrootdMonHeader hdr;
0082        int                tBeg;     // time(0) of the first record
0083        int                tEnd;     // time(0) of the last  record
0084        kXR_int64          sID;      // Server id in lower 48 bits
0085 };                                  // Information provider top 8 bits.
0086 
0087 struct XrdXrootdMonMap
0088        {XrdXrootdMonHeader hdr;
0089         kXR_unt32          dictid;
0090         char               info[1024+256];
0091        };
0092   
0093 const kXR_char XROOTD_MON_APPID         = 0xa0;
0094 const kXR_char XROOTD_MON_CLOSE         = 0xc0;
0095 const kXR_char XROOTD_MON_DISC          = 0xd0;
0096 const kXR_char XROOTD_MON_OPEN          = 0x80;
0097 const kXR_char XROOTD_MON_READV         = 0x90;
0098 const kXR_char XROOTD_MON_READU         = 0x91;
0099 const kXR_char XROOTD_MON_REDHOST       = 0xf0; // No   Modifier
0100 const kXR_char XROOTD_MON_WINDOW        = 0xe0;
0101 
0102 
0103 const kXR_char XROOTD_MON_MAPIDNT       = '=';
0104 const kXR_char XROOTD_MON_MAPPATH       = 'd';
0105 const kXR_char XROOTD_MON_MAPFSTA       = 'f'; // The "f" stream
0106 const kXR_char XROOTD_MON_MAPGSTA       = 'g'; // The "g" stream
0107 const kXR_char XROOTD_MON_MAPINFO       = 'i';
0108 const kXR_char XROOTD_MON_MAPMIGR       = 'm'; // Internal use only!
0109 const kXR_char XROOTD_MON_MAPPURG       = 'p';
0110 const kXR_char XROOTD_MON_MAPREDR       = 'r';
0111 const kXR_char XROOTD_MON_MAPSTAG       = 's'; // Internal use only!
0112 const kXR_char XROOTD_MON_MAPTRCE       = 't';
0113 const kXR_char XROOTD_MON_MAPTOKN       = 'T';
0114 const kXR_char XROOTD_MON_MAPUSER       = 'u';
0115 const kXR_char XROOTD_MON_MAPUEAC       = 'U'; // User experiment/activity
0116 const kXR_char XROOTD_MON_MAPXFER       = 'x';
0117 
0118 const kXR_char XROOTD_MON_GSCCM         = 'M'; // pfc: Cache context mgt info
0119 const kXR_char XROOTD_MON_GSPFC         = 'C'; // pfc: Cache monitoring  info
0120 const kXR_char XROOTD_MON_GSTCP         = 'T'; // TCP connection statistics
0121 const kXR_char XROOTD_MON_GSTPC         = 'P'; // TPC Third Party Copy
0122 const kXR_char XROOTD_MON_GSTHR         = 'R'; // IO activity from the throttle plugin
0123 
0124 // The following bits are insert in the low order 4 bits of the MON_REDIRECT
0125 // entry code to indicate the actual operation that was requestded.
0126 //
0127 const kXR_char XROOTD_MON_REDSID        = 0xf0; // Server Identification
0128 const kXR_char XROOTD_MON_REDTIME       = 0x00; // Timing mark
0129 
0130 const kXR_char XROOTD_MON_REDIRECT      = 0x80; // With Modifier below!
0131 const kXR_char XROOTD_MON_REDLOCAL      = 0x90; // With Modifier below!
0132 
0133 const kXR_char XROOTD_MON_CHMOD         = 0x01; // Modifiers for the above
0134 const kXR_char XROOTD_MON_LOCATE        = 0x02;
0135 const kXR_char XROOTD_MON_OPENDIR       = 0x03;
0136 const kXR_char XROOTD_MON_OPENC         = 0x04;
0137 const kXR_char XROOTD_MON_OPENR         = 0x05;
0138 const kXR_char XROOTD_MON_OPENW         = 0x06;
0139 const kXR_char XROOTD_MON_MKDIR         = 0x07;
0140 const kXR_char XROOTD_MON_MV            = 0x08;
0141 const kXR_char XROOTD_MON_PREP          = 0x09;
0142 const kXR_char XROOTD_MON_QUERY         = 0x0a;
0143 const kXR_char XROOTD_MON_RM            = 0x0b;
0144 const kXR_char XROOTD_MON_RMDIR         = 0x0c;
0145 const kXR_char XROOTD_MON_STAT          = 0x0d;
0146 const kXR_char XROOTD_MON_TRUNC         = 0x0e;
0147 
0148 const kXR_char XROOTD_MON_FORCED        = 0x01;
0149 const kXR_char XROOTD_MON_BOUNDP        = 0x02;
0150 
0151 const int      XROOTD_MON_REDMASK       = 0x00000ff;
0152 const int      XROOTD_MON_SRCMASK       = 0x000000f;
0153 const int      XROOTD_MON_TRGMASK       = 0x7fffff0;
0154 const int      XROOTD_MON_NEWSTID       = 0x8000000;
0155 
0156 const long long XROOTD_MON_SIDMASK      = 0x0000ffffffffffff;
0157 const long long XROOTD_MON_PIDMASK      = 0xff;
0158 const long long XROOTD_MON_PIDSHFT      = 56;
0159 
0160 /******************************************************************************/
0161 /*           " f "   S t r e a m   S p e c i f i c   R e c o r d s            */
0162 /******************************************************************************/
0163 
0164 // The UDP buffer layout is as follows:
0165 //
0166 // XrdXrootdMonHeader    with Code    ==  XROOTD_MON_MAPFSTA
0167 // XrdXrootdMonFileTOD   with recType == isTime
0168 // XrdXrootdMonFileHdr   with recType == one of recTval   (variable length)
0169 // ...                   additional XrdXrootdMonFileHdr's (variable length)
0170 // XrdXrootdMonFileTOD   with recType == isTime
0171   
0172 struct XrdXrootdMonFileHdr    // 8
0173 {
0174 enum  recTval {isClose = 0,   // Record for close
0175                isOpen,        // Record for open
0176                isTime,        // Record for time
0177                isXfr,         // Record for transfers
0178                isDisc         // Record for disconnection
0179               };
0180 
0181 enum  recFval {forced  =0x01, // If recFlag == isClose close due to disconnect
0182                hasOPS  =0x02, // If recFlag == isClose MonStatXFR + MonStatOPS
0183                hasSSQ  =0x04, // If recFlag == isClose XFR + OPS  + MonStatSSQ
0184                hasCSE  =0x04, // If recFlag == isClose XFR + OPS  + MonStatSSQ
0185                hasLFN  =0x01, // If recFlag == isOpen  the lfn is present
0186                hasRW   =0x02, // If recFlag == isOpen  file opened r/w
0187                hasSID  =0x01  // if recFlag == isTime sID is present (new rec)
0188               };
0189 
0190 char      recType;  // RecTval: isClose | isOpen | isTime | isXfr
0191 char      recFlag;  // RecFval: Record type-specific flags
0192 short     recSize;  // Size of this record in bytes
0193 union
0194 {
0195 kXR_unt32 fileID;   // dictid  of file for all rectypes except "disc" & "time"
0196 kXR_unt32 userID;   // dictid  of user for     rectypes equal  "disc"
0197 short     nRecs[2]; // isTime: nRecs[0] == isXfr recs nRecs[1] == total recs
0198 };
0199 };
0200 
0201 // The following record is always be present as the first record in the udp
0202 // udp packet and should be used to establish the recording window.
0203 //
0204 struct XrdXrootdMonFileTOD
0205 {
0206 XrdXrootdMonFileHdr Hdr;      //  8
0207 int                 tBeg;     // time(0) of following record
0208 int                 tEnd;     // time(0) when packet was sent
0209 kXR_int64           sID;      // Server id in lower 48 bits
0210 };
0211 
0212 
0213 // The following variable length structure exists in XrdXrootdMonFileOPN if
0214 // "lfn" has been specified. It exists only when recFlag & hasLFN is TRUE.
0215 // The user's dictid will be zero (missing) if user monitoring is not enabled.
0216 //
0217 struct XrdXrootdMonFileLFN
0218 {
0219 kXR_unt32           user;     // Monitoring dictid for the user, may be 0.
0220 char                lfn[1028];// Variable length, use recSize!
0221 };
0222 
0223 // The following is reported when a file is opened. If "lfn" was specified and
0224 // Hdr.recFlag & hasLFN is TRUE the XrdXrootdMonFileLFN structure is present.
0225 // However, it variable in size and the next record will be found using recSize.
0226 // The lfn is gauranteed to end with at least one null byte.
0227 //
0228 struct XrdXrootdMonFileOPN
0229 {
0230 XrdXrootdMonFileHdr Hdr;      //  8
0231 long long           fsz;      //  8 file size at time of open
0232 XrdXrootdMonFileLFN ufn;      //  Present ONLY if recFlag & hasLFN is TRUE
0233 };
0234 
0235 // The following data is collected on a per file basis
0236 //
0237 struct XrdXrootdMonStatPRW    //  8 Bytes
0238 {
0239 long long           rBytes;   // Bytes read  from file so far using pgread()
0240 int                 rCount;   // Number of operations
0241 int                 rRetry;   // Number of pgread  retries (pages)
0242 long long           wBytes;   // Bytes written to file so far using pgwrite()
0243 int                 wCount;   // Number of operations
0244 int                 wRetry;   // Number of pgwrite retries (corrections)
0245 int                 wcsErr;   // Number of pgwrite checksum errors
0246 int                 wcsUnc;   // Number of pgwrite uncorrected checksums
0247 };
0248 
0249 struct XrdXrootdMonStatOPS    // 48 Bytes
0250 {
0251 int                 read;     // Number of read()  calls
0252 int                 readv;    // Number of readv() calls
0253 int                 write;    // Number of write() calls
0254 short               rsMin;    // Smallest  readv() segment count
0255 short               rsMax;    // Largest   readv() segment count
0256 long long           rsegs;    // Number of readv() segments
0257 int                 rdMin;    // Smallest  read()  request size
0258 int                 rdMax;    // Largest   read()  request size
0259 int                 rvMin;    // Smallest  readv() request size
0260 int                 rvMax;    // Largest   readv() request size
0261 int                 wrMin;    // Smallest  write() request size
0262 int                 wrMax;    // Largest   write() request size
0263 };
0264 
0265 union XrdXrootdMonDouble
0266 {
0267 long long           dlong;
0268 double              dreal;
0269 };
0270 
0271 struct XrdXrootdMonStatSSQ    // 32 Bytes (all values net ordered IEEE754)
0272 {
0273 XrdXrootdMonDouble  read;     // Sum (all read  requests)**2 (size)
0274 XrdXrootdMonDouble  readv;    // Sum (all readv requests)**2 (size  as a unit)
0275 XrdXrootdMonDouble  rsegs;    // Sum (all readv segments)**2 (count as a unit)
0276 XrdXrootdMonDouble  write;    // Sum (all write requests)**2 (size)
0277 };
0278 
0279 // The following transfer data is collected for each open file.
0280 //
0281 struct XrdXrootdMonStatXFR
0282 {
0283 long long           read;     // Bytes read  from file so far using read()
0284 long long           readv;    // Bytes read  from file so far using readv()
0285 long long           write;    // Bytes written to file so far
0286 };
0287 
0288 // The following is reported upon file close. This is a variable length record.
0289 // The record always contains XrdXrootdMonStatXFR after   XrdXrootdMonFileHdr.
0290 // If (recFlag & hasOPS) TRUE XrdXrootdMonStatOPS follows XrdXrootdMonStatXFR
0291 // If (recFlag & hasSSQ) TRUE XrdXrootdMonStatSQV follows XrdXrootdMonStatOPS
0292 // The XrdXrootdMonStatSSQ information is present only if "ssq" was specified.
0293 //
0294 struct XrdXrootdMonFileCLS    // 32 | 80 | 96 Bytes
0295 {
0296 XrdXrootdMonFileHdr Hdr;      // Always present (recSize has full length)
0297 XrdXrootdMonStatXFR Xfr;      // Always present
0298 XrdXrootdMonStatOPS Ops;      // Only   present when (recFlag & hasOPS) is True
0299 XrdXrootdMonStatSSQ Ssq;      // Only   present when (recFlag & hasSSQ) is True
0300 };
0301 
0302 // The following is reported when a user ends a session.
0303 //
0304 struct XrdXrootdMonFileDSC
0305 {
0306 XrdXrootdMonFileHdr Hdr;      //  8
0307 };
0308 
0309 // The following is reported each interval*count for each open file when "xfr"
0310 // is specified. These records may be interspersed with other records.
0311 //
0312 struct XrdXrootdMonFileXFR    // 32 Bytes
0313 {
0314 XrdXrootdMonFileHdr Hdr;      // Always present with recType == isXFR
0315 XrdXrootdMonStatXFR Xfr;      // Always present
0316 };
0317 #endif