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_SRCMASK = 0x000000f; 00136 const int XROOTD_MON_TRGMASK = 0x7fffff0; 00137 const int XROOTD_MON_NEWSTID = 0x8000000; 00138 00139 /******************************************************************************/ 00140 /* " f " S t r e a m S p e c i f i c R e c o r d s */ 00141 /******************************************************************************/ 00142 00143 // The UDP buffer layout is as follows: 00144 // 00145 // XrdXrootdMonHeader with Code == XROOTD_MON_MAPFSTA 00146 // XrdXrootdMonFileTOD with recType == isTime 00147 // XrdXrootdMonFileHdr with recType == one of recTval (variable length) 00148 // ... additional XrdXrootdMonFileHdr's (variable length) 00149 // XrdXrootdMonFileTOD with recType == isTime 00150 00151 struct XrdXrootdMonFileHdr // 8 00152 { 00153 enum recTval {isClose = 0, // Record for close 00154 isOpen, // Record for open 00155 isTime, // Record for time 00156 isXfr, // Record for transfers 00157 isDisc // Record for disconnection 00158 }; 00159 00160 enum recFval {forced =0x01, // If recFlag == isClose close due to disconnect 00161 hasOPS =0x02, // If recFlag == isClose MonStatXFR + MonStatOPS 00162 hasSSQ =0x04, // If recFlag == isClose XFR + OPS + MonStatSSQ 00163 hasLFN =0x01, // If recFlag == isOpen the lfn is present 00164 hasRW =0x02, // If recFlag == isOpen file opened r/w 00165 hasSID =0x01 // if recFlag == isTime sID is present (new rec) 00166 }; 00167 00168 char recType; // RecTval: isClose | isOpen | isTime | isXfr 00169 char recFlag; // RecFval: Record type-specific flags 00170 short recSize; // Size of this record in bytes 00171 union 00172 { 00173 kXR_unt32 fileID; // dictid of file for all rectypes except "disc" & "time" 00174 kXR_unt32 userID; // dictid of user for rectypes equal "disc" 00175 short nRecs[2]; // isTime: nRecs[0] == isXfr recs nRecs[1] == total recs 00176 }; 00177 }; 00178 00179 // The following record is always be present as the first record in the udp 00180 // udp packet and should be used to establish the recording window. 00181 // 00182 struct XrdXrootdMonFileTOD 00183 { 00184 XrdXrootdMonFileHdr Hdr; // 8 00185 int tBeg; // time(0) of following record 00186 int tEnd; // time(0) when packet was sent 00187 kXR_int64 sID; // Server id in lower 48 bits 00188 }; 00189 00190 00191 // The following variable length structure exists in XrdXrootdMonFileOPN if 00192 // "lfn" has been specified. It exists only when recFlag & hasLFN is TRUE. 00193 // The user's dictid will be zero (missing) if user monitoring is not enabled. 00194 // 00195 struct XrdXrootdMonFileLFN 00196 { 00197 kXR_unt32 user; // Monitoring dictid for the user, may be 0. 00198 char lfn[1028];// Variable length, use recSize! 00199 }; 00200 00201 // The following is reported when a file is opened. If "lfn" was specified and 00202 // Hdr.recFlag & hasLFN is TRUE the XrdXrootdMonFileLFN structure is present. 00203 // However, it variable in size and the next record will be found using recSize. 00204 // The lfn is gauranteed to end with at least one null byte. 00205 // 00206 struct XrdXrootdMonFileOPN 00207 { 00208 XrdXrootdMonFileHdr Hdr; // 8 00209 long long fsz; // 8 file size at time of open 00210 XrdXrootdMonFileLFN ufn; // Present ONLY if recFlag & hasLFN is TRUE 00211 }; 00212 00213 // The following data is collected on a per file basis 00214 // 00215 struct XrdXrootdMonStatOPS // 48 Bytes 00216 { 00217 int read; // Number of read() calls 00218 int readv; // Number of readv() calls 00219 int write; // Number of write() calls 00220 short rsMin; // Smallest readv() segment count 00221 short rsMax; // Largest readv() segment count 00222 long long rsegs; // Number of readv() segments 00223 int rdMin; // Smallest read() request size 00224 int rdMax; // Largest read() request size 00225 int rvMin; // Smallest readv() request size 00226 int rvMax; // Largest readv() request size 00227 int wrMin; // Smallest write() request size 00228 int wrMax; // Largest write() request size 00229 }; 00230 00231 union XrdXrootdMonDouble 00232 { 00233 long long dlong; 00234 double dreal; 00235 }; 00236 00237 struct XrdXrootdMonStatSSQ // 32 Bytes (all values net ordered IEEE754) 00238 { 00239 XrdXrootdMonDouble read; // Sum (all read requests)**2 (size) 00240 XrdXrootdMonDouble readv; // Sum (all readv requests)**2 (size as a unit) 00241 XrdXrootdMonDouble rsegs; // Sum (all readv segments)**2 (count as a unit) 00242 XrdXrootdMonDouble write; // Sum (all write requests)**2 (size) 00243 }; 00244 00245 // The following transfer data is collected for each open file. 00246 // 00247 struct XrdXrootdMonStatXFR 00248 { 00249 long long read; // Bytes read from file so far using read() 00250 long long readv; // Bytes read from file so far using readv() 00251 long long write; // Bytes written to file so far 00252 }; 00253 00254 // The following is reported upon file close. This is a variable length record. 00255 // The record always contains XrdXrootdMonStatXFR after XrdXrootdMonFileHdr. 00256 // If (recFlag & hasOPS) TRUE XrdXrootdMonStatOPS follows XrdXrootdMonStatXFR 00257 // If (recFlag & hasSSQ) TRUE XrdXrootdMonStatSQV follows XrdXrootdMonStatOPS 00258 // The XrdXrootdMonStatSSQ information is present only if "ssq" was specified. 00259 // 00260 struct XrdXrootdMonFileCLS // 32 | 80 | 96 Bytes 00261 { 00262 XrdXrootdMonFileHdr Hdr; // Always present (recSize has full length) 00263 XrdXrootdMonStatXFR Xfr; // Always present 00264 XrdXrootdMonStatOPS Ops; // Only present when (recFlag & hasOPS) is True 00265 XrdXrootdMonStatSSQ Ssq; // Only present when (recFlag & hasSSQ) is True 00266 }; 00267 00268 // The following is reported when a user ends a session. 00269 // 00270 struct XrdXrootdMonFileDSC 00271 { 00272 XrdXrootdMonFileHdr Hdr; // 8 00273 }; 00274 00275 // The following is reported each interval*count for each open file when "xfr" 00276 // is specified. These records may be interspersed with other records. 00277 // 00278 struct XrdXrootdMonFileXFR // 32 Bytes 00279 { 00280 XrdXrootdMonFileHdr Hdr; // Always present with recType == isXFR 00281 XrdXrootdMonStatXFR Xfr; // Always present 00282 }; 00283 #endif