![]() |
|
|||
0001 /** 0002 * @brief LCF API (published) 0003 * 0004 * @file lcf.h 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #ifndef LCF_H_ 0035 #define LCF_H_ 0036 0037 #if defined(__cplusplus) 0038 extern "C" { 0039 #endif 0040 0041 /*---------------------------Includes-----------------------------------*/ 0042 #include <ndrx_config.h> 0043 #include <limits.h> 0044 #include <sys/types.h> 0045 #include <nstopwatch.h> 0046 0047 /*---------------------------Externs------------------------------------*/ 0048 /*---------------------------Macros-------------------------------------*/ 0049 /** Number of pages used to flip-flop the active DDR routing SHM area */ 0050 #define NDRX_LCF_FEEDBACK_BUF 64 /**< ASCII feedback buffer from command */ 0051 #define NDRX_LCF_ADMINCMD_MAX 32 /**< Admin command max lenght */ 0052 #define NDRX_LCF_ADMINDSCR_MAX 128 /**< Max description for admin cmd */ 0053 0054 #define NDRX_LCF_FLAG_PID 0x00000001 /**< Interpret PID as regexp, xadmin */ 0055 #define NDRX_LCF_FLAG_BIN 0x00000002 /**< Interpret BINNAME as regexp, xadmin */ 0056 #define NDRX_LCF_FLAG_ALL 0x00000004 /**< Apply to all processes, xadmin */ 0057 #define NDRX_LCF_FLAG_ARGA 0x00000008 /**< Arg A required, xadmin reg, chk args */ 0058 #define NDRX_LCF_FLAG_ARGB 0x00000010 /**< Arg B required, xadmin reg, chk args */ 0059 #define NDRX_LCF_FLAG_DOSTARTUP 0x00000020 /**< Execute command at startup, xadmin, xadmin reg default+ */ 0060 #define NDRX_LCF_FLAG_DOSTARTUPEXP 0x00000040 /**< Execute at startup, having w expiry, xadmin reg default+ */ 0061 #define NDRX_LCF_FLAG_DOREX 0x00000080 /**< Check BIN or PID by regexp */ 0062 0063 #define NDRX_LCF_FLAG_FBACK_CODE 0x00000100 /**< Feedback code is loaded */ 0064 #define NDRX_LCF_FLAG_FBACK_MSG 0x00000200 /**< Feedback msg is loaded */ 0065 0066 /**< Callback reg struct version (ndrx_lcf_reg_func_t) */ 0067 #define NDRX_LCF_CCMD_VERSION 1 0068 /**< Xadmin command version (ndrx_lcf_reg_xadmin_t) */ 0069 #define NDRX_LCF_XCMD_VERSION 1 0070 /**< LCF Command version (ndrx_lcf_command_t) */ 0071 #define NDRX_LCF_LCMD_VERSION 1 0072 0073 #define NDRX_LCF_CMD_MIN 0 /**< minimum accepted command */ 0074 #define NDRX_LCF_CMD_DISABLE 0 /**< Command is disabled */ 0075 #define NDRX_LCF_CMD_LOGROTATE 1 /**< Perfrom logrotated */ 0076 #define NDRX_LCF_CMD_LOGCHG 2 /**< Change logger params */ 0077 #define NDRX_LCF_CMD_MAX_PROD 999 /**< Maximum product command */ 0078 #define NDRX_LCF_CMD_MIN_CUST 1000 /**< Minimum user command code */ 0079 #define NDRX_LCF_CMD_MAX_CUST 1999 /**< Maximum user command code */ 0080 0081 #define NDRX_LCF_CMDSTR_DISABLE "disable" 0082 #define NDRX_LCF_CMDSTR_LOGROTATE "logrotate" 0083 #define NDRX_LCF_CMDSTR_LOGCHG "logchg" 0084 0085 #define NDRX_LCF_SLOT_LOGROTATE 0 /**< Default command slot for logrotate */ 0086 #define NDRX_LCF_SLOT_LOGCHG 1 /**< Default slot for log re-configure */ 0087 0088 #define NDRX_NAME_MAX 64 /**< Name max */ 0089 0090 /*---------------------------Enums--------------------------------------*/ 0091 /*---------------------------Typedefs-----------------------------------*/ 0092 0093 /* LCF will provide shared memory block */ 0094 0095 /** 0096 * Actual command for LCF data 0097 * For command registration: 0098 * - Have a plugin call to register the commands (id, name, arg A / B / none / descr). 0099 * these will appear in xadmin lcf <command> 0100 * - Have a plugin to export a callbacks for the LCF command. So that user 0101 * application may implement handlers 0102 */ 0103 typedef struct 0104 { 0105 /* The command: */ 0106 int version; /**< Version number of the c struct */ 0107 unsigned cmdversion; /**< command version, so that if we switch the logs check that 0108 * command is not changed (i.e. we want to update the stats) */ 0109 0110 char cmdstr[NDRX_LCF_ADMINCMD_MAX+1]; /**< Command code $ xadmin lcf <code> */ 0111 0112 ndrx_stopwatch_t publtim;/**< Time when command was published */ 0113 int command; /**< Command code */ 0114 char arg_a[PATH_MAX+1]; /**< Argument a */ 0115 char arg_b[NDRX_NAME_MAX+1]; /**< Argument b, shorter to save some memor */ 0116 long flags; /**< LCF Command flags */ 0117 0118 /* To whom: */ 0119 char procid[NDRX_NAME_MAX]; /**< PID or program name */ 0120 0121 /* To metrics: */ 0122 int applied; /**< binaries applied the command */ 0123 int failed; /**< either regexp failed, or the target callback failed */ 0124 int seen; /**< Number of processes seen, but not matched */ 0125 long fbackcode; /**< Feedback code from last who executed, user changed */ 0126 char fbackmsg[NDRX_LCF_FEEDBACK_BUF]; /**< Feedback message, user chnaged */ 0127 0128 } ndrx_lcf_command_t; 0129 0130 0131 /** 0132 * Standard library configuration managed by lcf 0133 */ 0134 typedef struct 0135 { 0136 int version; /**< API version */ 0137 int command; /**< lcf comand code */ 0138 char cmdstr[NDRX_LCF_ADMINCMD_MAX+1]; /**< For debug purposes */ 0139 0140 /** API receives copy (snapshoot) of mem block 0141 * @param cmd this is constant and must not be changed by process 0142 * it is data from shared memory directly. 0143 * @param flags output flags about feedback: NDRX_LCF_FLAG_FBACK*. On input value is 0. 0144 * @return EXSUCCEED/EXFAIL 0145 */ 0146 int (*pf_callback)(ndrx_lcf_command_t *cmd, long *p_flags); 0147 0148 } ndrx_lcf_reg_func_t; 0149 0150 /** 0151 * Register command with xadmin 0152 */ 0153 typedef struct 0154 { 0155 int version; /**< API version */ 0156 char cmdstr[NDRX_LCF_ADMINCMD_MAX+1]; /**< Command code $ xadmin lcf <code> */ 0157 int command; /**< lcf comand code */ 0158 char helpstr[NDRX_LCF_ADMINDSCR_MAX+1]; /**< Help text for command */ 0159 long dfltflags; /**< ARGA, ARGB, DOSTARTUP, DOSTARTUPDEL */ 0160 int dfltslot; /**< Default slot numbere wher command shall be installed */ 0161 } ndrx_lcf_reg_xadmin_t; 0162 0163 0164 /*---------------------------Globals------------------------------------*/ 0165 /*---------------------------Statics------------------------------------*/ 0166 /*---------------------------Prototypes---------------------------------*/ 0167 0168 extern NDRX_API int ndrx_lcf_xadmin_add(ndrx_lcf_reg_xadmin_t *xcmd); 0169 extern NDRX_API int ndrx_lcf_func_add(ndrx_lcf_reg_func_t *cfunc); 0170 extern NDRX_API int ndrx_lcf_publish(int slot, ndrx_lcf_command_t *cmd); 0171 0172 #if defined(__cplusplus) 0173 } 0174 #endif 0175 0176 #endif 0177 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |