XrdXrootdStats.cc

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /*                     X r d X r o o t d S t a t s . c c                      */
00004 /*                                                                            */
00005 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University  */
00006 /*       All Rights Reserved. See XrdInfo.cc for complete License Terms       */
00007 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00008 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00009 /******************************************************************************/
00010 
00011 //        $Id: XrdXrootdStats.cc 29874 2009-08-21 16:56:04Z ganis $
00012 
00013 const char *XrdXrootdStatsCVSID = "$Id: XrdXrootdStats.cc 29874 2009-08-21 16:56:04Z ganis $";
00014  
00015 #include <stdio.h>
00016   
00017 #include "Xrd/XrdStats.hh"
00018 #include "XrdSfs/XrdSfsInterface.hh"
00019 #include "XrdXrootd/XrdXrootdResponse.hh"
00020 #include "XrdXrootd/XrdXrootdStats.hh"
00021  
00022 /******************************************************************************/
00023 /*                           C o n s t r c u t o r                            */
00024 /******************************************************************************/
00025   
00026 XrdXrootdStats::XrdXrootdStats(XrdStats *sp)
00027 {
00028 
00029 xstats   = sp;
00030 
00031 Count    = 0;     // Stats: Number of matches
00032 errorCnt = 0;     // Stats: Number of errors returned
00033 redirCnt = 0;     // Stats: Number of redirects
00034 stallCnt = 0;     // Stats: Number of stalls
00035 getfCnt  = 0;     // Stats: Number of getfiles
00036 putfCnt  = 0;     // Stats: Number of putfiles
00037 openCnt  = 0;     // Stats: Number of opens
00038 readCnt  = 0;     // Stats: Number of reads
00039 prerCnt  = 0;     // Stats: Number of reads
00040 writeCnt = 0;     // Stats: Number of writes
00041 syncCnt  = 0;     // Stats: Number of sync
00042 miscCnt  = 0;     // Stats: Number of miscellaneous
00043 AsyncNum = 0;     // Stats: Number of async ops
00044 AsyncMax = 0;     // Stats: Number of async max
00045 AsyncRej = 0;     // Stats: Number of async rejected
00046 AsyncNow = 0;     // Stats: Number of async now (not locked)
00047 Refresh  = 0;     // Stats: Number of refresh requests
00048 }
00049 
00050 /******************************************************************************/
00051 /*                                 S t a t s                                  */
00052 /******************************************************************************/
00053   
00054 int XrdXrootdStats::Stats(char *buff, int blen, int do_sync)
00055 {
00056    static const char statfmt[] = "<stats id=\"xrootd\"><num>%d</num>"
00057    "<ops><open>%d</open><rf>%d</rf><rd>%d</rd><pr>%d</pr><wr>%d</wr>"
00058    "<sync>%d</sync><getf>%d</getf><putf>%d</putf><misc>%d</misc></ops>"
00059    "<aio><num>%d</num><max>%d</max><rej>%d</rej></aio></stats>";
00060    int len;
00061 
00062 // If no buffer, caller wants the maximum size we will generate
00063 //
00064    if (!buff) return sizeof(statfmt) + (16*13) + (fsP ? fsP->getStats(0,0) : 0);
00065 
00066 // Format our statistics
00067 //
00068    statsMutex.Lock();
00069    len = snprintf(buff, blen, statfmt, Count, openCnt, Refresh, readCnt,
00070                   prerCnt, writeCnt, syncCnt, getfCnt, putfCnt, miscCnt,
00071                   AsyncNum, AsyncMax, AsyncRej);
00072    statsMutex.UnLock();
00073 
00074 // Now include filesystem statistics and return
00075 //
00076    if (fsP) len += fsP->getStats(buff+len, blen-len);
00077    return len;
00078 }
00079  
00080 /******************************************************************************/
00081 /*                                 S t a t s                                  */
00082 /******************************************************************************/
00083   
00084 int XrdXrootdStats::Stats(XrdXrootdResponse &resp, const char *opts)
00085 {
00086     int i, xopts = 0;
00087 
00088     while(*opts)
00089          {switch(*opts)
00090                 {case 'a': xopts |= XRD_STATS_ALL;  break;
00091                  case 'b': xopts |= XRD_STATS_BUFF; break;    // b_uff
00092                  case 'i': xopts |= XRD_STATS_INFO; break;    // i_nfo
00093                  case 'l': xopts |= XRD_STATS_LINK; break;    // l_ink
00094                  case 'd': xopts |= XRD_STATS_POLL; break;    // d_evice
00095                  case 'u': xopts |= XRD_STATS_PROC; break;    // u_sage
00096                  case 'p': xopts |= XRD_STATS_PROT; break;    // p_rotocol
00097                  case 's': xopts |= XRD_STATS_SCHD; break;    // s_scheduler
00098                  default:  break;
00099                 }
00100           opts++;
00101          }
00102 
00103     if (!xopts) return resp.Send();
00104 
00105     xstats->Lock();
00106     i = resp.Send(xstats->Stats(xopts));
00107     xstats->UnLock();
00108     return i;
00109 }

Generated on Tue Jul 5 14:47:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1