XRootD
XrdOfsStats.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* */
3 /* X r d O f s S t a t s . c c */
4 /* */
5 /* (c) 2009 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* Produced by Andrew Hanushevsky for Stanford University under contract */
7 /* DE-AC02-76-SFO0515 with the Department of Energy */
8 /* */
9 /* This file is part of the XRootD software suite. */
10 /* */
11 /* XRootD is free software: you can redistribute it and/or modify it under */
12 /* the terms of the GNU Lesser General Public License as published by the */
13 /* Free Software Foundation, either version 3 of the License, or (at your */
14 /* option) any later version. */
15 /* */
16 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19 /* License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24 /* */
25 /* The copyright holder's institutional names and contributor's names may not */
26 /* be used to endorse or promote products derived from this software without */
27 /* specific prior written permission of the institution or contributor. */
28 /******************************************************************************/
29 
30 #include <cstdio>
31 
32 #include "XrdOfs/XrdOfsStats.hh"
33 
34 /******************************************************************************/
35 /* R e p o r t */
36 /******************************************************************************/
37 
38 int XrdOfsStats::Report(char *buff, int blen)
39 {
40  static const char stats1[] = "<stats id=\"ofs\"><role>%s</role>"
41  "<opr>%d</opr><opw>%d</opw><opp>%d</opp><ups>%d</ups><han>%d</han>"
42  "<rdr>%d</rdr><bxq>%d</bxq><rep>%d</rep><err>%d</err><dly>%d</dly>"
43  "<sok>%d</sok><ser>%d</ser>"
44  "<tpc><grnt>%d</grnt><deny>%d</deny><err>%d</err><exp>%d</exp></tpc>"
45  "</stats>";
46  static const int statsz = sizeof(stats1) + (12*10) + 64;
47 
48  StatsData myData;
49 
50 // If only the size is wanted, return the size
51 //
52  if (!buff) return statsz;
53 
54 // Make sure buffer is large enough
55 //
56  if (blen < statsz) return 0;
57 
58 // Get a copy of the statistics
59 //
60  sdMutex.Lock();
61  myData = Data;
62  sdMutex.UnLock();
63 
64 // Format the buffer
65 //
66  return sprintf(buff, stats1, myRole, myData.numOpenR, myData.numOpenW,
67  myData.numOpenP, myData.numUnpsist, myData.numHandles,
68  myData.numRedirect, myData.numStarted, myData.numReplies,
69  myData.numErrors, myData.numDelays,
70  myData.numSeventOK, myData.numSeventER,
71  myData.numTPCgrant, myData.numTPCdeny,
72  myData.numTPCerrs, myData.numTPCexpr);
73 }
struct XrdOfsStats::StatsData Data
int Report(char *Buff, int Blen)
Definition: XrdOfsStats.cc:38
XrdSysMutex sdMutex
Definition: XrdOfsStats.hh:60