00001 #ifndef __XRDXROOTDMONDATA__ 00002 #define __XRDXROOTDMONDATA__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d X r o o t d M o n D a t a . h h */ 00006 /* */ 00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include "XProtocol/XPtypes.hh" 00034 00035 /******************************************************************************/ 00036 /* P a c k e t D e f i n i t i o n s */ 00037 /******************************************************************************/ 00038 00039 struct XrdXrootdMonHeader 00040 {kXR_char code; // '='|'d'|'f'|'i'|'p'|'r'|'t'|'u'|'x' 00041 kXR_char pseq; // packet sequence 00042 kXR_unt16 plen; // packet length 00043 kXR_int32 stod; // Unix time at Server Start 00044 }; 00045 00046 struct XrdXrootdMonTrace 00047 {union {kXR_int64 val; 00048 kXR_char id[8]; 00049 kXR_unt16 sVal[4]; 00050 kXR_unt32 rTot[2]; } arg0; 00051 union {kXR_int32 buflen; 00052 kXR_int32 Window; 00053 kXR_unt32 wTot; } arg1; 00054 union {kXR_unt32 dictid; 00055 kXR_int32 Window; } arg2; 00056 }; 00057 00058 struct XrdXrootdMonBuff 00059 {XrdXrootdMonHeader hdr; 00060 XrdXrootdMonTrace info[sizeof(XrdXrootdMonTrace)]; //This is really [n] 00061 }; 00062 00063 struct XrdXrootdMonRedir 00064 {union {kXR_int32 Window; 00065 struct {kXR_char Type; 00066 kXR_char Dent; 00067 kXR_int16 Port; 00068 } rdr; } arg0; 00069 union {kXR_unt32 dictid; 00070 kXR_int32 Window; } arg1; 00071 }; 00072 00073 struct XrdXrootdMonBurr 00074 {XrdXrootdMonHeader hdr; 00075 union {kXR_int64 sID; 00076 kXR_char sXX[8]; }; 00077 XrdXrootdMonRedir info[sizeof(XrdXrootdMonRedir)]; //This is really [n] 00078 }; 00079 00080 struct XrdXrootdMonGS 00081 {XrdXrootdMonHeader hdr; 00082 int tBeg; // time(0) of the first record 00083 int tEnd; // time(0) of the last record 00084 kXR_int64 sID; // Server id in lower 48 bits 00085 }; // Information provider top 8 bits. 00086 00087 struct XrdXrootdMonMap 00088 {XrdXrootdMonHeader hdr; 00089 kXR_unt32 dictid; 00090 char info[1024+256]; 00091 }; 00092 00093 const kXR_char XROOTD_MON_APPID = 0xa0; 00094 const kXR_char XROOTD_MON_CLOSE = 0xc0; 00095 const kXR_char XROOTD_MON_DISC = 0xd0; 00096 const kXR_char XROOTD_MON_OPEN = 0x80; 00097 const kXR_char XROOTD_MON_READV = 0x90; 00098 const kXR_char XROOTD_MON_READU = 0x91; 00099 const kXR_char XROOTD_MON_REDHOST = 0xf0; // No Modifier 00100 const kXR_char XROOTD_MON_WINDOW = 0xe0; 00101 00102 00103 const kXR_char XROOTD_MON_MAPIDNT = '='; 00104 const kXR_char XROOTD_MON_MAPPATH = 'd'; 00105 const kXR_char XROOTD_MON_MAPFSTA = 'f'; // The "f" stream 00106 const kXR_char XROOTD_MON_MAPGSTA = 'g'; // The "g" stream 00107 const kXR_char XROOTD_MON_MAPINFO = 'i'; 00108 const kXR_char XROOTD_MON_MAPMIGR = 'm'; // Internal use only! 00109 const kXR_char XROOTD_MON_MAPPURG = 'p'; 00110 const kXR_char XROOTD_MON_MAPREDR = 'r'; 00111 const kXR_char XROOTD_MON_MAPSTAG = 's'; // Internal use only! 00112 const kXR_char XROOTD_MON_MAPTRCE = 't'; 00113 const kXR_char XROOTD_MON_MAPUSER = 'u'; 00114 const kXR_char XROOTD_MON_MAPXFER = 'x'; 00115 00116 const kXR_char XROOTD_MON_GSCCM = 'M'; // pfc: Cache context mgt info 00117 const kXR_char XROOTD_MON_GSPFC = 'C'; // pfc: Cache monitoring info 00118 const kXR_char XROOTD_MON_GSTCP = 'T'; // TCP connection statistics 00119 00120 // The following bits are insert in the low order 4 bits of the MON_REDIRECT 00121 // entry code to indicate the actual operation that was requestded. 00122 // 00123 const kXR_char XROOTD_MON_REDSID = 0xf0; // Server Identification 00124 const kXR_char XROOTD_MON_REDTIME = 0x00; // Timing mark 00125 00126 const kXR_char XROOTD_MON_REDIRECT = 0x80; // With Modifier below! 00127 const kXR_char XROOTD_MON_REDLOCAL = 0x90; // With Modifier below! 00128 00129 const kXR_char XROOTD_MON_CHMOD = 0x01; // Modifiers for the above 00130 const kXR_char XROOTD_MON_LOCATE = 0x02; 00131 const kXR_char XROOTD_MON_OPENDIR = 0x03; 00132 const kXR_char XROOTD_MON_OPENC = 0x04; 00133 const kXR_char XROOTD_MON_OPENR = 0x05; 00134 const kXR_char XROOTD_MON_OPENW = 0x06; 00135 const kXR_char XROOTD_MON_MKDIR = 0x07; 00136 const kXR_char XROOTD_MON_MV = 0x08; 00137 const kXR_char XROOTD_MON_PREP = 0x09; 00138 const kXR_char XROOTD_MON_QUERY = 0x0a; 00139 const kXR_char XROOTD_MON_RM = 0x0b; 00140 const kXR_char XROOTD_MON_RMDIR = 0x0c; 00141 const kXR_char XROOTD_MON_STAT = 0x0d; 00142 const kXR_char XROOTD_MON_TRUNC = 0x0e; 00143 00144 const kXR_char XROOTD_MON_FORCED = 0x01; 00145 const kXR_char XROOTD_MON_BOUNDP = 0x02; 00146 00147 const int XROOTD_MON_REDMASK = 0x00000ff; 00148 const int XROOTD_MON_SRCMASK = 0x000000f; 00149 const int XROOTD_MON_TRGMASK = 0x7fffff0; 00150 const int XROOTD_MON_NEWSTID = 0x8000000; 00151 00152 const long long XROOTD_MON_SIDMASK = 0x0000ffffffffffff; 00153 const long long XROOTD_MON_PIDMASK = 0xff; 00154 const long long XROOTD_MON_PIDSHFT = 56; 00155 00156 /******************************************************************************/ 00157 /* " f " S t r e a m S p e c i f i c R e c o r d s */ 00158 /******************************************************************************/ 00159 00160 // The UDP buffer layout is as follows: 00161 // 00162 // XrdXrootdMonHeader with Code == XROOTD_MON_MAPFSTA 00163 // XrdXrootdMonFileTOD with recType == isTime 00164 // XrdXrootdMonFileHdr with recType == one of recTval (variable length) 00165 // ... additional XrdXrootdMonFileHdr's (variable length) 00166 // XrdXrootdMonFileTOD with recType == isTime 00167 00168 struct XrdXrootdMonFileHdr // 8 00169 { 00170 enum recTval {isClose = 0, // Record for close 00171 isOpen, // Record for open 00172 isTime, // Record for time 00173 isXfr, // Record for transfers 00174 isDisc // Record for disconnection 00175 }; 00176 00177 enum recFval {forced =0x01, // If recFlag == isClose close due to disconnect 00178 hasOPS =0x02, // If recFlag == isClose MonStatXFR + MonStatOPS 00179 hasSSQ =0x04, // If recFlag == isClose XFR + OPS + MonStatSSQ 00180 hasLFN =0x01, // If recFlag == isOpen the lfn is present 00181 hasRW =0x02, // If recFlag == isOpen file opened r/w 00182 hasSID =0x01 // if recFlag == isTime sID is present (new rec) 00183 }; 00184 00185 char recType; // RecTval: isClose | isOpen | isTime | isXfr 00186 char recFlag; // RecFval: Record type-specific flags 00187 short recSize; // Size of this record in bytes 00188 union 00189 { 00190 kXR_unt32 fileID; // dictid of file for all rectypes except "disc" & "time" 00191 kXR_unt32 userID; // dictid of user for rectypes equal "disc" 00192 short nRecs[2]; // isTime: nRecs[0] == isXfr recs nRecs[1] == total recs 00193 }; 00194 }; 00195 00196 // The following record is always be present as the first record in the udp 00197 // udp packet and should be used to establish the recording window. 00198 // 00199 struct XrdXrootdMonFileTOD 00200 { 00201 XrdXrootdMonFileHdr Hdr; // 8 00202 int tBeg; // time(0) of following record 00203 int tEnd; // time(0) when packet was sent 00204 kXR_int64 sID; // Server id in lower 48 bits 00205 }; 00206 00207 00208 // The following variable length structure exists in XrdXrootdMonFileOPN if 00209 // "lfn" has been specified. It exists only when recFlag & hasLFN is TRUE. 00210 // The user's dictid will be zero (missing) if user monitoring is not enabled. 00211 // 00212 struct XrdXrootdMonFileLFN 00213 { 00214 kXR_unt32 user; // Monitoring dictid for the user, may be 0. 00215 char lfn[1028];// Variable length, use recSize! 00216 }; 00217 00218 // The following is reported when a file is opened. If "lfn" was specified and 00219 // Hdr.recFlag & hasLFN is TRUE the XrdXrootdMonFileLFN structure is present. 00220 // However, it variable in size and the next record will be found using recSize. 00221 // The lfn is gauranteed to end with at least one null byte. 00222 // 00223 struct XrdXrootdMonFileOPN 00224 { 00225 XrdXrootdMonFileHdr Hdr; // 8 00226 long long fsz; // 8 file size at time of open 00227 XrdXrootdMonFileLFN ufn; // Present ONLY if recFlag & hasLFN is TRUE 00228 }; 00229 00230 // The following data is collected on a per file basis 00231 // 00232 struct XrdXrootdMonStatOPS // 48 Bytes 00233 { 00234 int read; // Number of read() calls 00235 int readv; // Number of readv() calls 00236 int write; // Number of write() calls 00237 short rsMin; // Smallest readv() segment count 00238 short rsMax; // Largest readv() segment count 00239 long long rsegs; // Number of readv() segments 00240 int rdMin; // Smallest read() request size 00241 int rdMax; // Largest read() request size 00242 int rvMin; // Smallest readv() request size 00243 int rvMax; // Largest readv() request size 00244 int wrMin; // Smallest write() request size 00245 int wrMax; // Largest write() request size 00246 }; 00247 00248 union XrdXrootdMonDouble 00249 { 00250 long long dlong; 00251 double dreal; 00252 }; 00253 00254 struct XrdXrootdMonStatSSQ // 32 Bytes (all values net ordered IEEE754) 00255 { 00256 XrdXrootdMonDouble read; // Sum (all read requests)**2 (size) 00257 XrdXrootdMonDouble readv; // Sum (all readv requests)**2 (size as a unit) 00258 XrdXrootdMonDouble rsegs; // Sum (all readv segments)**2 (count as a unit) 00259 XrdXrootdMonDouble write; // Sum (all write requests)**2 (size) 00260 }; 00261 00262 // The following transfer data is collected for each open file. 00263 // 00264 struct XrdXrootdMonStatXFR 00265 { 00266 long long read; // Bytes read from file so far using read() 00267 long long readv; // Bytes read from file so far using readv() 00268 long long write; // Bytes written to file so far 00269 }; 00270 00271 // The following is reported upon file close. This is a variable length record. 00272 // The record always contains XrdXrootdMonStatXFR after XrdXrootdMonFileHdr. 00273 // If (recFlag & hasOPS) TRUE XrdXrootdMonStatOPS follows XrdXrootdMonStatXFR 00274 // If (recFlag & hasSSQ) TRUE XrdXrootdMonStatSQV follows XrdXrootdMonStatOPS 00275 // The XrdXrootdMonStatSSQ information is present only if "ssq" was specified. 00276 // 00277 struct XrdXrootdMonFileCLS // 32 | 80 | 96 Bytes 00278 { 00279 XrdXrootdMonFileHdr Hdr; // Always present (recSize has full length) 00280 XrdXrootdMonStatXFR Xfr; // Always present 00281 XrdXrootdMonStatOPS Ops; // Only present when (recFlag & hasOPS) is True 00282 XrdXrootdMonStatSSQ Ssq; // Only present when (recFlag & hasSSQ) is True 00283 }; 00284 00285 // The following is reported when a user ends a session. 00286 // 00287 struct XrdXrootdMonFileDSC 00288 { 00289 XrdXrootdMonFileHdr Hdr; // 8 00290 }; 00291 00292 // The following is reported each interval*count for each open file when "xfr" 00293 // is specified. These records may be interspersed with other records. 00294 // 00295 struct XrdXrootdMonFileXFR // 32 Bytes 00296 { 00297 XrdXrootdMonFileHdr Hdr; // Always present with recType == isXFR 00298 XrdXrootdMonStatXFR Xfr; // Always present 00299 }; 00300 #endif