XRootD
XrdMonitor.hh
Go to the documentation of this file.
1 #ifndef __XRDMONITOR__
2 #define __XRDMONITOR__
3 /******************************************************************************/
4 /* */
5 /* X r d M o n i t o r . h h */
6 /* */
7 /* (c) 2024 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /******************************************************************************/
31 
32 #include <map>
33 #include <cstring>
34 #include <vector>
35 
36 #include "Xrd/XrdMonRoll.hh"
37 
39 {
40 public:
41 
42 // Format Options:
43 //
44 enum Mopts {F_JSON = 0x10000000, X_PLUG = 0x00000001, X_ADON = 0x00000002};
45 
46 int Format(char* buff, int bsize, int& item, int opts=0);
47 
48 int Format(char* buff, int bsize, const char* setName, int opts=0);
49 
50 bool Register(XrdMonRoll::rollType setType, const char* setName,
51  XrdMonRoll::Item itemVec[], int itemCnt);
52 
53 bool Registered() {return !regVec.empty();}
54 
57 
58 private:
59 
60 using MRIFam = XrdMonRoll::Item::Family;
61 using MRISch = XrdMonRoll::Item::Schema;
62 using MRITrt = XrdMonRoll::Item::Trait;
63 
64 enum sType {isAdon=0x00000001, isPlug=0x00000002};
65 
66 struct RegInfo
67  {char* typName;
68  char* setName;
69  char* Json_hdr = 0;
70  char* Xml_hdr = 0;
71  char* eTmplt;
72  sType setType;
73  int iCount = 0;
74  XrdMonRoll::Item* iVec = 0;
75 
76  RegInfo(const char* sName, const char* tName, sType sTVal);
77 
78  ~RegInfo();
79  };
80 
81 std::vector<RegInfo*> regVec;
82 
83 RegInfo* FindSet(const char* setName, int sType);
84 int FormJSON(RegInfo& regInfo, char* buff, int bsize);
85 int FormXML( RegInfo& regInfo, char* buff, int bsize);
86 bool RegFail(const char* TName, const char* SName, const char* why);
87 int V2S(RegInfo& rI, XrdMonRoll::Item& iR, char* buff, int blen);
88 int V2T(RegInfo& rI, XrdMonRoll::Item& iR, char* buff, int blen, bool ij);
89 void ValEnd(bool& isBad, XrdMonitor::RegInfo& rI, const char* aoT,
90  const char* begKey, XrdMonRoll::Item* endP);
91 bool ValErr(RegInfo& regInfo, int iNum, const char* etxt);
92 void ValKey(bool& isBad, RegInfo& rI, XrdMonRoll::Item* itemP);
93 bool Validate(RegInfo& regInfo);
94 };
95 #endif
struct myOpts opts
bool Register(XrdMonRoll::rollType setType, const char *setName, XrdMonRoll::Item itemVec[], int itemCnt)
Definition: XrdMonitor.cc:308
int Format(char *buff, int bsize, int &item, int opts=0)
Definition: XrdMonitor.cc:104
bool Registered()
Definition: XrdMonitor.hh:53