|
||||
0001 /** 0002 * @brief Memory checking routines 0003 * 0004 * @file exmemck.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 EXMEMCK_H 0035 #define EXMEMCK_H 0036 0037 0038 #if defined(__cplusplus) 0039 extern "C" { 0040 #endif 0041 /*---------------------------Includes-----------------------------------*/ 0042 #include <ndrx_config.h> 0043 #include <exhash.h> 0044 #include <nstopwatch.h> 0045 #include <regex.h> 0046 /*---------------------------Externs------------------------------------*/ 0047 /*---------------------------Macros-------------------------------------*/ 0048 #define EXMEMCK_STATUS_OK 0x0000 /* OK, no memory leaks detected */ 0049 #define EXMEMCK_STATUS_LEAKY_RSS 0x0001 /* Leak detected, RSS */ 0050 #define EXMEMCK_STATUS_LEAKY_VSZ 0x0002 /* Leak detected, VSZ */ 0051 /*---------------------------Enums--------------------------------------*/ 0052 /*---------------------------Typedefs-----------------------------------*/ 0053 0054 typedef struct exmemck_process exmemck_process_t; 0055 0056 /* So we need two structures here: 0057 * 1. Configuration 0058 * 2. Per process statistics 0059 */ 0060 0061 struct exmemck_settings 0062 { 0063 long mem_limit; 0064 int percent_diff_allow; 0065 int interval_start_prcnt; 0066 int interval_stop_prcnt; 0067 long flags; 0068 int interval_mon; /* Interval into which monitor memory (with out exit).. */ 0069 char negative_mask[PATH_MAX]; /* Negative mask (must not match), optional */ 0070 int min_values; /* minimum values for each halve */ 0071 /* Have a callback for status notification */ 0072 void (*pf_proc_exit) (exmemck_process_t *proc); 0073 void (*pf_proc_leaky) (exmemck_process_t *proc); 0074 0075 }; 0076 0077 typedef struct exmemck_settings exmemck_settings_t; 0078 0079 /** 0080 * Memory check config 0081 */ 0082 struct exmemck_config 0083 { 0084 char mask[PATH_MAX+1]; 0085 char dlft_mask[PATH_MAX+1]; 0086 regex_t mask_regex; /* compiled mask */ 0087 int neg_mask_used; /* Is negative mask used? */ 0088 regex_t neg_mask_regex; /* compiled negative mask */ 0089 0090 exmemck_settings_t settings; 0091 ndrx_stopwatch_t mon_watch; /*monitor stopwatch if set interval mon*/ 0092 0093 EX_hash_handle hh; 0094 }; 0095 typedef struct exmemck_config exmemck_config_t; 0096 0097 /** 0098 * Statistics entry point... 0099 */ 0100 struct exmemck_statentry 0101 { 0102 long rss; 0103 long vsz; 0104 }; 0105 typedef struct exmemck_statentry exmemck_statentry_t; 0106 0107 /** 0108 * Definition of client processes (full command line & all settings) 0109 */ 0110 struct exmemck_process 0111 { 0112 int pid; /* which pid we are monitoring */ 0113 0114 char psout[PATH_MAX+1]; /* ps string we are monitoring */ 0115 0116 exmemck_config_t *p_config; /* when removing config, exmemck_process shall be removed too */ 0117 exmemck_statentry_t *stats; /* Array of statistics */ 0118 int nr_of_stats; /* Number array elements... */ 0119 0120 int status; /* Calculated status */ 0121 0122 int avg_first_count; /* number of records for first halve */ 0123 long avg_first_halve_rss; /* first halve average bytes */ 0124 long avg_second_halve_rss; /* second halve average bytes */ 0125 0126 int avg_second_count; /* number of records for second halve */ 0127 long avg_first_halve_vsz; /* first halve average bytes */ 0128 long avg_second_halve_vsz; /* second halve average bytes */ 0129 0130 double rss_increase_prcnt; 0131 double vsz_increase_prcnt; 0132 0133 int proc_exists; /* check for process existence... */ 0134 0135 EX_hash_handle hh; /* makes this structure hashable */ 0136 }; 0137 0138 /*---------------------------Globals------------------------------------*/ 0139 /*---------------------------Statics------------------------------------*/ 0140 /*---------------------------Prototypes---------------------------------*/ 0141 extern NDRX_API int ndrx_memck_add(char *mask, char *dlft_mask, 0142 exmemck_settings_t *p_settings); 0143 extern NDRX_API int ndrx_memck_rm(char *mask); 0144 extern NDRX_API void ndrx_memck_rmall(void); 0145 extern NDRX_API exmemck_process_t* ndrx_memck_getstats_single(pid_t pid); 0146 extern NDRX_API exmemck_process_t* ndrx_memck_getstats(void); 0147 extern NDRX_API void ndrx_memck_reset(char *mask); 0148 extern NDRX_API void ndrx_memck_reset_pid(pid_t pid); 0149 extern NDRX_API int ndrx_memck_tick(void); 0150 0151 #if defined(__cplusplus) 0152 } 0153 #endif 0154 0155 0156 #endif 0157 /* 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 |