00001 /* 00002 * $Id: snmpstats.h 4764 2008-08-28 14:41:06Z henningw $ 00003 * 00004 * SNMPStats Module 00005 * Copyright (C) 2006 SOMA Networks, INC. 00006 * Written by: Jeffrey Magder (jmagder@somanetworks.com) 00007 * 00008 * This file is part of Kamailio, a free SIP server. 00009 * 00010 * Kamailio is free software; you can redistribute it and/or modify it 00011 * under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version 00014 * 00015 * Kamailio is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 * USA 00024 * 00025 * History: 00026 * -------- 00027 * 2006-11-23 initial version (jmagder) 00028 * 00029 * Structure and prototype definitions for the SNMPStats module. 00030 * 00031 * There are some important points to understanding the SNMPStat modules 00032 * architecture. 00033 * 00034 * 1) The SNMPStats module will fork off a new process in mod_child_init when 00035 * the rank is equal to PROC_MAIN_PROCESS. The sub-process will be 00036 * responsible for registering with a master agent (the source of snmp 00037 * requests), and handling all received requests. 00038 * 00039 * 2) The Module will register a periodic alarm checking function with a sip 00040 * timer using register_timer(). This function checks for alarm conditions, 00041 * and will send out traps to the master agent when it detects their 00042 * presence. 00043 * 00044 * 3) The SNMPStats module is required to run an external application upon 00045 * startup, to collect sysUpTime data from the master agent. This involves 00046 * spawning a short-lived process. For this reason, the module temporarily 00047 * installs a new SIGCHLD handler to deal specifically with this process. It 00048 * does not change the normal SIGCHLD behaviour for any process except for 00049 * this short lived sysUpTime process. 00050 * 00051 * 4) mod_init() will initialize some interprocess communication buffers, as 00052 * well as callback mechanisms for the usrloc module. To understand what the 00053 * interprocess buffer and callbacks are and are for, please see the 00054 * respective comments in interprocess_buffer.h, openserSIPRegUserTable.h, 00055 * and openserSIPContactTable.h. 00056 */ 00057 00058 /*! 00059 * \file 00060 * \brief SNMP statistic module 00061 * \ingroup snmpstats 00062 * - Module: \ref snmpstats 00063 */ 00064 00065 #ifndef _SNMP_STATS_ 00066 #define _SNMP_STATS_ 00067 00068 #include "../../statistics.h" 00069 #include "../../sr_module.h" 00070 #include "../../dprint.h" 00071 #include "../../error.h" 00072 #include "../../ut.h" 00073 #include "../../script_cb.h" 00074 #include "../../mem/mem.h" 00075 #include "../../mem/shm_mem.h" 00076 #include "snmpstats_globals.h" 00077 #include "sub_agent.h" 00078 00079 #define SNMPSTATS_MODULE_NAME "snmpstats" 00080 #define SYSUPTIME_OID ".1.3.6.1.2.1.1.3.0" 00081 00082 /*! This is the first function to be called by Kamailio, to initialize the module. 00083 * This call must always return a value as soon as possible. If it were not to 00084 * return, then Kamailio would not be able to initialize any of the other 00085 * modules. */ 00086 static int mod_init(void); 00087 00088 /*! This function is called when Kamailio has finished creating all instances of 00089 * itself. It is at this point that we want to create our AgentX sub-agent 00090 * process, and register a handler for any state changes of our child. */ 00091 static int mod_child_init(int rank); 00092 00093 00094 /*! This function is called when Kamailio is shutting down. When this happens, we 00095 * log a useful message and kill the AgentX Sub-Agent child process */ 00096 static void mod_destroy(void); 00097 00098 00099 static proc_export_t mod_procs[] = { 00100 {"SNMP AgentX", 0, 0, agentx_child, 1 }, 00101 {0,0,0,0,0} 00102 }; 00103 00104 00105 /*! 00106 * This structure defines the SNMPStats parameters that can be configured 00107 * through the kamailio.cfg configuration file. 00108 */ 00109 static param_export_t mod_params[] = 00110 { 00111 { "sipEntityType", STR_PARAM|USE_FUNC_PARAM, 00112 (void *)handleSipEntityType }, 00113 { "MsgQueueMinorThreshold", INT_PARAM|USE_FUNC_PARAM, 00114 (void *)set_queue_minor_threshold }, 00115 { "MsgQueueMajorThreshold", INT_PARAM|USE_FUNC_PARAM, 00116 (void *)set_queue_major_threshold }, 00117 { "dlg_minor_threshold", INT_PARAM|USE_FUNC_PARAM, 00118 (void *)set_dlg_minor_threshold }, 00119 { "dlg_major_threshold", INT_PARAM|USE_FUNC_PARAM, 00120 (void *)set_dlg_major_threshold }, 00121 { "snmpgetPath", STR_PARAM|USE_FUNC_PARAM, 00122 (void *)set_snmpget_path }, 00123 { "snmpCommunity", STR_PARAM|USE_FUNC_PARAM, 00124 (void *)set_snmp_community }, 00125 { 0,0,0 } 00126 }; 00127 00128 00129 struct module_exports exports = 00130 { 00131 SNMPSTATS_MODULE_NAME, /* module's name */ 00132 DEFAULT_DLFLAGS, /* dlopen flags */ 00133 0, /* exported functions */ 00134 mod_params, /* param exports */ 00135 0, /* exported statistics */ 00136 0, /* MI Functions */ 00137 0, /* pseudo-variables */ 00138 mod_procs, /* extra processes */ 00139 mod_init, /* module initialization function */ 00140 0, /* reply processing function */ 00141 mod_destroy, /* Destroy function */ 00142 mod_child_init /* per-child init function */ 00143 }; 00144 00145 #endif
1.5.6