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 XrdXrootdMonMap 00081 {XrdXrootdMonHeader hdr; 00082 kXR_unt32 dictid; 00083 char info[1024+256]; 00084 }; 00085 00086 const kXR_char XROOTD_MON_APPID = 0xa0; 00087 const kXR_char XROOTD_MON_CLOSE = 0xc0; 00088 const kXR_char XROOTD_MON_DISC = 0xd0; 00089 const kXR_char XROOTD_MON_OPEN = 0x80; 00090 const kXR_char XROOTD_MON_READV = 0x90; 00091 const kXR_char XROOTD_MON_READU = 0x91; 00092 const kXR_char XROOTD_MON_REDHOST = 0xf0; // No Modifier 00093 const kXR_char XROOTD_MON_WINDOW = 0xe0; 00094 00095 00096 const kXR_char XROOTD_MON_MAPIDNT = '='; 00097 const kXR_char XROOTD_MON_MAPPATH = 'd'; 00098 const kXR_char XROOTD_MON_MAPFSTA = 'f'; // The "f" stream 00099 const kXR_char XROOTD_MON_MAPINFO = 'i'; 00100 const kXR_char XROOTD_MON_MAPMIGR = 'm'; // Internal use only! 00101 const kXR_char XROOTD_MON_MAPPURG = 'p'; 00102 const kXR_char XROOTD_MON_MAPREDR = 'r'; 00103 const kXR_char XROOTD_MON_MAPSTAG = 's'; // Internal use only! 00104 const kXR_char XROOTD_MON_MAPTRCE = 't'; 00105 const kXR_char XROOTD_MON_MAPUSER = 'u'; 00106 const kXR_char XROOTD_MON_MAPXFER = 'x'; 00107 00108 // The following bits are insert in the low order 4 bits of the MON_REDIRECT 00109 // entry code to indicate the actual operation that was requestded. 00110 // 00111 const kXR_char XROOTD_MON_REDSID = 0xf0; // Server Identification 00112 const kXR_char XROOTD_MON_REDTIME = 0x00; // Timing mark 00113 00114 const kXR_char XROOTD_MON_REDIRECT = 0x80; // With Modifier below! 00115 const kXR_char XROOTD_MON_REDLOCAL = 0x90; // With Modifier below! 00116 00117 const kXR_char XROOTD_MON_CHMOD = 0x01; // Modifiers for the above 00118 const kXR_char XROOTD_MON_LOCATE = 0x02; 00119 const kXR_char XROOTD_MON_OPENDIR = 0x03; 00120 const kXR_char XROOTD_MON_OPENC = 0x04; 00121 const kXR_char XROOTD_MON_OPENR = 0x05; 00122 const kXR_char XROOTD_MON_OPENW = 0x06; 00123 const kXR_char XROOTD_MON_MKDIR = 0x07; 00124 const kXR_char XROOTD_MON_MV = 0x08; 00125 const kXR_char XROOTD_MON_PREP = 0x09; 00126 const kXR_char XROOTD_MON_QUERY = 0x0a; 00127 const kXR_char XROOTD_MON_RM = 0x0b; 00128 const kXR_char XROOTD_MON_RMDIR = 0x0c; 00129 const kXR_char XROOTD_MON_STAT = 0x0d; 00130 const kXR_char XROOTD_MON_TRUNC = 0x0e; 00131 00132 const kXR_char XROOTD_MON_FORCED = 0x01; 00133 const kXR_char XROOTD_MON_BOUNDP = 0x02; 00134 00135 const int XROOTD_MON_REDMASK = 0x00000ff; 00136 const int XROOTD_MON_SRCMASK = 0x000000f; 00137 const int XROOTD_MON_TRGMASK = 0x7fffff0; 00138 const int XROOTD_MON_NEWSTID = 0x8000000; 00139 00140 /******************************************************************************/ 00141 /* " f " S t r e a m S p e c i f i c R e c o r d s */ 00142 /******************************************************************************/ 00143 00144 // The UDP buffer layout is as follows: 00145 // 00146 // XrdXrootdMonHeader with Code == XROOTD_MON_MAPFSTA 00147 // XrdXrootdMonFileTOD with recType == isTime 00148 // XrdXrootdMonFileHdr with recType == one of recTval (variable length) 00149 // ... additional XrdXrootdMonFileHdr's (variable length) 00150 // XrdXrootdMonFileTOD with recType == isTime 00151 00152 struct XrdXrootdMonFileHdr // 8 00153 { 00154 enum recTval {isClose = 0, // Record for close 00155 isOpen, // Record for open 00156 isTime, // Record for time 00157 isXfr, // Record for transfers 00158 isDisc // Record for disconnection 00159 }; 00160 00161 enum recFval {forced =0x01, // If recFlag == isClose close due to disconnect 00162 hasOPS =0x02, // If recFlag == isClose MonStatXFR + MonStatOPS 00163 hasSSQ =0x04, // If recFlag == isClose XFR + OPS + MonStatSSQ 00164 hasLFN =0x01, // If recFlag == isOpen the lfn is present 00165 hasRW =0x02, // If recFlag == isOpen file opened r/w 00166 hasSID =0x01 // if recFlag == isTime sID is present (new rec) 00167 }; 00168 00169 char recType; // RecTval: isClose | isOpen | isTime | isXfr 00170 char recFlag; // RecFval: Record type-specific flags 00171 short recSize; // Size of this record in bytes 00172 union 00173 { 00174 kXR_unt32 fileID; // dictid of file for all rectypes except "disc" & "time" 00175 kXR_unt32 userID; // dictid of user for rectypes equal "disc" 00176 short nRecs[2]; // isTime: nRecs[0] == isXfr recs nRecs[1] == total recs 00177 }; 00178 }; 00179 00180 // The following record is always be present as the first record in the udp 00181 // udp packet and should be used to establish the recording window. 00182 // 00183 struct XrdXrootdMonFileTOD 00184 { 00185 XrdXrootdMonFileHdr Hdr; // 8 00186 int tBeg; // time(0) of following record 00187 int tEnd; // time(0) when packet was sent 00188 kXR_int64 sID; // Server id in lower 48 bits 00189 }; 00190 00191 00192 // The following variable length structure exists in XrdXrootdMonFileOPN if 00193 // "lfn" has been specified. It exists only when recFlag & hasLFN is TRUE. 00194 // The user's dictid will be zero (missing) if user monitoring is not enabled. 00195 // 00196 struct XrdXrootdMonFileLFN 00197 { 00198 kXR_unt32 user; // Monitoring dictid for the user, may be 0. 00199 char lfn[1028];// Variable length, use recSize! 00200 }; 00201 00202 // The following is reported when a file is opened. If "lfn" was specified and 00203 // Hdr.recFlag & hasLFN is TRUE the XrdXrootdMonFileLFN structure is present. 00204 // However, it variable in size and the next record will be found using recSize. 00205 // The lfn is gauranteed to end with at least one null byte. 00206 // 00207 struct XrdXrootdMonFileOPN 00208 { 00209 XrdXrootdMonFileHdr Hdr; // 8 00210 long long fsz; // 8 file size at time of open 00211 XrdXrootdMonFileLFN ufn; // Present ONLY if recFlag & hasLFN is TRUE 00212 }; 00213 00214 // The following data is collected on a per file basis 00215 // 00216 struct XrdXrootdMonStatOPS // 48 Bytes 00217 { 00218 int read; // Number of read() calls 00219 int readv; // Number of readv() calls 00220 int write; // Number of write() calls 00221 short rsMin; // Smallest readv() segment count 00222 short rsMax; // Largest readv() segment count 00223 long long rsegs; // Number of readv() segments 00224 int rdMin; // Smallest read() request size 00225 int rdMax; // Largest read() request size 00226 int rvMin; // Smallest readv() request size 00227 int rvMax; // Largest readv() request size 00228 int wrMin; // Smallest write() request size 00229 int wrMax; // Largest write() request size 00230 }; 00231 00232 union XrdXrootdMonDouble 00233 { 00234 long long dlong; 00235 double dreal; 00236 }; 00237 00238 struct XrdXrootdMonStatSSQ // 32 Bytes (all values net ordered IEEE754) 00239 { 00240 XrdXrootdMonDouble read; // Sum (all read requests)**2 (size) 00241 XrdXrootdMonDouble readv; // Sum (all readv requests)**2 (size as a unit) 00242 XrdXrootdMonDouble rsegs; // Sum (all readv segments)**2 (count as a unit) 00243 XrdXrootdMonDouble write; // Sum (all write requests)**2 (size) 00244 }; 00245 00246 // The following transfer data is collected for each open file. 00247 // 00248 struct XrdXrootdMonStatXFR 00249 { 00250 long long read; // Bytes read from file so far using read() 00251 long long readv; // Bytes read from file so far using readv() 00252 long long write; // Bytes written to file so far 00253 }; 00254 00255 // The following is reported upon file close. This is a variable length record. 00256 // The record always contains XrdXrootdMonStatXFR after XrdXrootdMonFileHdr. 00257 // If (recFlag & hasOPS) TRUE XrdXrootdMonStatOPS follows XrdXrootdMonStatXFR 00258 // If (recFlag & hasSSQ) TRUE XrdXrootdMonStatSQV follows XrdXrootdMonStatOPS 00259 // The XrdXrootdMonStatSSQ information is present only if "ssq" was specified. 00260 // 00261 struct XrdXrootdMonFileCLS // 32 | 80 | 96 Bytes 00262 { 00263 XrdXrootdMonFileHdr Hdr; // Always present (recSize has full length) 00264 XrdXrootdMonStatXFR Xfr; // Always present 00265 XrdXrootdMonStatOPS Ops; // Only present when (recFlag & hasOPS) is True 00266 XrdXrootdMonStatSSQ Ssq; // Only present when (recFlag & hasSSQ) is True 00267 }; 00268 00269 // The following is reported when a user ends a session. 00270 // 00271 struct XrdXrootdMonFileDSC 00272 { 00273 XrdXrootdMonFileHdr Hdr; // 8 00274 }; 00275 00276 // The following is reported each interval*count for each open file when "xfr" 00277 // is specified. These records may be interspersed with other records. 00278 // 00279 struct XrdXrootdMonFileXFR // 32 Bytes 00280 { 00281 XrdXrootdMonFileHdr Hdr; // Always present with recType == isXFR 00282 XrdXrootdMonStatXFR Xfr; // Always present 00283 }; 00284 #endif