Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-08 10:33:37

0001 #ifndef __CMS_PERFMON__
0002 #define __CMS_PERFMON__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                      X r d C m s P e r f M o n . h h                       */
0006 /*                                                                            */
0007 /* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 class  XrdOucEnv;
0034 class  XrdSysLogger;
0035 
0036 /******************************************************************************/
0037 /*                   c l a s s   X r d C m s P e r f M o n                    */
0038 /******************************************************************************/
0039 
0040 /* The XrdCmsPerfMon is used to report performance metrics. It is obtained
0041    from the shared library loaded at run time and identified by the cms.perf
0042    directive. The library should contain an implementation of this class.
0043 */
0044   
0045 class XrdCmsPerfMon
0046 {
0047 public:
0048 
0049 //------------------------------------------------------------------------------
0050 //! Configure the PerfMon plugin object. This is called after the plugin
0051 //! is loaded via the shared library.
0052 //!
0053 //! @param  cfn     The configuration file name.
0054 //! @param  Parms   Any parameters specified in the perf directive. If none,
0055 //!                 the pointer may be null.
0056 //! @param  Logger  The logging object.
0057 //! @param  cmsMon  The object to be used for async reporting.
0058 //! @param  EnvInfo Environmental information of the caller, may be nil.
0059 //! @param  isCMS   True if loaded by the cmsd and false if loaded by xrootd.
0060 //!
0061 //! @return True  upon success.
0062 //!         False upon failure.
0063 //------------------------------------------------------------------------------
0064 
0065 virtual bool   Configure(const char    *cfn,
0066                                char    *Parms,
0067                          XrdSysLogger  &Logger,
0068                          XrdCmsPerfMon &cmsMon,
0069                          XrdOucEnv     *EnvInfo,
0070                          bool           isCMS)
0071                         {(void)cfn; (void)Parms; (void)Logger; (void)cmsMon;
0072                          (void)EnvInfo; (void)isCMS;
0073                          return false;
0074                         }
0075 
0076 //------------------------------------------------------------------------------
0077 //! Structure used for reporting performance metrics.
0078 //------------------------------------------------------------------------------
0079 
0080 struct PerfInfo
0081       {unsigned char cpu_load; //!< CPU       0 to 100 utilization
0082        unsigned char mem_load; //!< Memory    0 to 100 utilization
0083        unsigned char net_load; //!< Network   0 to 100 utilization
0084        unsigned char pag_load; //!< Paging    0 to 100 utilization
0085        unsigned char xeq_load; //!< Other     0 to 100 utilization (arbitrary)
0086        unsigned char xxx_load; //!< Reserved
0087        unsigned char yyy_load; //!< Reserved
0088        unsigned char zzz_load; //!< Reserved
0089 
0090        void Clear() {cpu_load = mem_load = net_load = pag_load = xeq_load = 0;
0091                      xxx_load = yyy_load = zzz_load = 0;
0092                     }
0093 
0094        PerfInfo() {Clear();}
0095       ~PerfInfo() {}
0096       };
0097 
0098 //------------------------------------------------------------------------------
0099 //! Obtain performance statistics as load values from 0 to 100. The system
0100 //! calls this method at periodic intervals.
0101 //!
0102 //! @param  info  Reference to the structure that should be filled out with
0103 //!               load values, as desired. See the PerfInfo structure.
0104 //------------------------------------------------------------------------------
0105 
0106 virtual void   GetInfo(PerfInfo &info) {(void)info;}
0107 
0108 //------------------------------------------------------------------------------
0109 //! Report performance statistics as load values from 0 to 100. The performance
0110 //! monitor plugin may call this method to asynchronously report performance
0111 //! via the passed XrdCmsPerfMon object during configuration.
0112 //!
0113 //! @param  info  Reference to the structure that should be filled out with
0114 //!               load values. See the PerfInfo structure.
0115 //! @param  alert When true, load information is forcibly sent to the cluster's
0116 //!               manager. Otherwise, it is only sent if it significantly
0117 //!               changes. See the cms.sched directive fuzz parameter.
0118 //------------------------------------------------------------------------------
0119 
0120 virtual void   PutInfo(PerfInfo &info, bool alert=false)
0121                       {(void)info; (void)alert;}
0122 
0123 //------------------------------------------------------------------------------
0124 //! Constructor & Destructor
0125 //------------------------------------------------------------------------------
0126 
0127                XrdCmsPerfMon() {}
0128 
0129 virtual       ~XrdCmsPerfMon() {}
0130 };
0131 
0132 /******************************************************************************/
0133 /*       L i b r a r y   X r d C m s P e r f M o n   D e f i n i i o n        */
0134 /******************************************************************************/
0135 
0136 //------------------------------------------------------------------------------
0137 //! Your implementation should inherit XrdCmsPerfMon and override the
0138 //! Configure() and GetInfo() methods. Your PutInfo() method will never be
0139 //! called. Then you should set the upcasted address of your implementation at
0140 //! file level as follows (note that use of new here is merely as example):
0141 //!
0142 //! XrdCmsPerfMon *XrdCmsPerfMonitor = new myPerfMon();
0143 //------------------------------------------------------------------------------
0144 
0145 //------------------------------------------------------------------------------
0146 //! Declare compilation version.
0147 //!
0148 //! Additionally, you *should* declare the xrootd version you used to compile
0149 //! your plug-in.
0150 //------------------------------------------------------------------------------
0151 
0152 /*! #include "XrdVersion.hh"
0153     XrdVERSIONINFO(XrdCmsPerfMonitor,<name>);
0154 
0155 */
0156 #endif