Module: sip-router
Branch: 3.1
Commit: cf783925a78100faeff4199a201ad46e7b58247c
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cf78392…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Jan 28 09:16:05 2011 +0100
snmpstats: start the agentx process
(cherry picked from commit 41e163ccd7ea6b52886e67928d453f454a239208)
---
modules_k/snmpstats/snmpstats.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/modules_k/snmpstats/snmpstats.c b/modules_k/snmpstats/snmpstats.c
index 9e52c03..248e693 100644
--- a/modules_k/snmpstats/snmpstats.c
+++ b/modules_k/snmpstats/snmpstats.c
@@ -266,6 +266,9 @@ static int mod_init(void)
/* Register the alarm checking function to run periodically */
register_timer(run_alarm_check, 0, ALARM_AGENT_FREQUENCY_IN_SECONDS);
+ /* add space for one extra process */
+ register_procs(1);
+
return 0;
}
@@ -275,11 +278,21 @@ static int mod_init(void)
* process, and register a handler for any state changes of our child. */
static int mod_child_init(int rank)
{
+ int pid;
+
/* We only want to setup a single process, under the main attendant. */
if (rank != PROC_MAIN) {
return 0;
}
+ pid=fork_process(PROC_NOCHLDINIT, "SNMP AgentX", 1);
+ if (pid<0)
+ return -1; /* error */
+ if(pid==0){
+ /* child */
+ agentx_child(1);
+ }
+
/* Spawn a child that will check the system up time. */
spawn_sysUpTime_child();
Module: sip-router
Branch: master
Commit: 8c26d7221cabe3c7c5b2f218b842c5886d830966
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8c26d72…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Jan 28 16:46:47 2011 +0100
snmpstats: moved declaration of vars in .c file
---
modules_k/snmpstats/snmpstats.c | 72 ++++++++++++++++++++++++++++++++++++++
modules_k/snmpstats/snmpstats.h | 73 ---------------------------------------
2 files changed, 72 insertions(+), 73 deletions(-)
diff --git a/modules_k/snmpstats/snmpstats.c b/modules_k/snmpstats/snmpstats.c
index 831251b..1994876 100644
--- a/modules_k/snmpstats/snmpstats.c
+++ b/modules_k/snmpstats/snmpstats.c
@@ -84,6 +84,15 @@
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include "../../lib/kcore/statistics.h"
+#include "../../sr_module.h"
+#include "../../dprint.h"
+#include "../../error.h"
+#include "../../ut.h"
+#include "../../script_cb.h"
+#include "../../mem/mem.h"
+#include "../../mem/shm_mem.h"
+
#include "snmpSIPRegUserTable.h"
#include "snmpSIPContactTable.h"
@@ -97,6 +106,69 @@
/* Required in every Kamailio Module. */
MODULE_VERSION
+/*! This is the first function to be called by Kamailio, to initialize the module.
+ * This call must always return a value as soon as possible. If it were not to
+ * return, then Kamailio would not be able to initialize any of the other
+ * modules. */
+static int mod_init(void);
+
+/*! This function is called when Kamailio has finished creating all instances of
+ * itself. It is at this point that we want to create our AgentX sub-agent
+ * process, and register a handler for any state changes of our child. */
+static int mod_child_init(int rank);
+
+
+/*! This function is called when Kamailio is shutting down. When this happens, we
+ * log a useful message and kill the AgentX Sub-Agent child process */
+static void mod_destroy(void);
+
+
+static proc_export_t mod_procs[] = {
+ {"SNMP AgentX", 0, 0, agentx_child, 1 },
+ {0,0,0,0,0}
+};
+
+
+/*!
+ * This structure defines the SNMPStats parameters that can be configured
+ * through the kamailio.cfg configuration file.
+ */
+static param_export_t mod_params[] =
+{
+ { "sipEntityType", STR_PARAM|USE_FUNC_PARAM,
+ (void *)handleSipEntityType },
+ { "MsgQueueMinorThreshold", INT_PARAM|USE_FUNC_PARAM,
+ (void *)set_queue_minor_threshold },
+ { "MsgQueueMajorThreshold", INT_PARAM|USE_FUNC_PARAM,
+ (void *)set_queue_major_threshold },
+ { "dlg_minor_threshold", INT_PARAM|USE_FUNC_PARAM,
+ (void *)set_dlg_minor_threshold },
+ { "dlg_major_threshold", INT_PARAM|USE_FUNC_PARAM,
+ (void *)set_dlg_major_threshold },
+ { "snmpgetPath", STR_PARAM|USE_FUNC_PARAM,
+ (void *)set_snmpget_path },
+ { "snmpCommunity", STR_PARAM|USE_FUNC_PARAM,
+ (void *)set_snmp_community },
+ { 0,0,0 }
+};
+
+
+struct module_exports exports =
+{
+ SNMPSTATS_MODULE_NAME, /* module's name */
+ DEFAULT_DLFLAGS, /* dlopen flags */
+ 0, /* exported functions */
+ mod_params, /* param exports */
+ 0, /* exported statistics */
+ 0, /* MI Functions */
+ 0, /* pseudo-variables */
+ mod_procs, /* extra processes */
+ mod_init, /* module initialization function */
+ 0, /* reply processing function */
+ mod_destroy, /* Destroy function */
+ mod_child_init /* per-child init function */
+};
+
/*!
* The module will fork off a child process to run an snmp command via execve().
* We need a customized handler to ignore the SIGCHLD when the execve()
diff --git a/modules_k/snmpstats/snmpstats.h b/modules_k/snmpstats/snmpstats.h
index 75a0160..6b76a2d 100644
--- a/modules_k/snmpstats/snmpstats.h
+++ b/modules_k/snmpstats/snmpstats.h
@@ -65,81 +65,8 @@
#ifndef _SNMP_STATS_
#define _SNMP_STATS_
-#include "../../lib/kcore/statistics.h"
-#include "../../sr_module.h"
-#include "../../dprint.h"
-#include "../../error.h"
-#include "../../ut.h"
-#include "../../script_cb.h"
-#include "../../mem/mem.h"
-#include "../../mem/shm_mem.h"
-#include "snmpstats_globals.h"
-#include "sub_agent.h"
-
#define SNMPSTATS_MODULE_NAME "snmpstats"
#define SYSUPTIME_OID ".1.3.6.1.2.1.1.3.0"
-/*! This is the first function to be called by Kamailio, to initialize the module.
- * This call must always return a value as soon as possible. If it were not to
- * return, then Kamailio would not be able to initialize any of the other
- * modules. */
-static int mod_init(void);
-
-/*! This function is called when Kamailio has finished creating all instances of
- * itself. It is at this point that we want to create our AgentX sub-agent
- * process, and register a handler for any state changes of our child. */
-static int mod_child_init(int rank);
-
-
-/*! This function is called when Kamailio is shutting down. When this happens, we
- * log a useful message and kill the AgentX Sub-Agent child process */
-static void mod_destroy(void);
-
-
-static proc_export_t mod_procs[] = {
- {"SNMP AgentX", 0, 0, agentx_child, 1 },
- {0,0,0,0,0}
-};
-
-
-/*!
- * This structure defines the SNMPStats parameters that can be configured
- * through the kamailio.cfg configuration file.
- */
-static param_export_t mod_params[] =
-{
- { "sipEntityType", STR_PARAM|USE_FUNC_PARAM,
- (void *)handleSipEntityType },
- { "MsgQueueMinorThreshold", INT_PARAM|USE_FUNC_PARAM,
- (void *)set_queue_minor_threshold },
- { "MsgQueueMajorThreshold", INT_PARAM|USE_FUNC_PARAM,
- (void *)set_queue_major_threshold },
- { "dlg_minor_threshold", INT_PARAM|USE_FUNC_PARAM,
- (void *)set_dlg_minor_threshold },
- { "dlg_major_threshold", INT_PARAM|USE_FUNC_PARAM,
- (void *)set_dlg_major_threshold },
- { "snmpgetPath", STR_PARAM|USE_FUNC_PARAM,
- (void *)set_snmpget_path },
- { "snmpCommunity", STR_PARAM|USE_FUNC_PARAM,
- (void *)set_snmp_community },
- { 0,0,0 }
-};
-
-
-struct module_exports exports =
-{
- SNMPSTATS_MODULE_NAME, /* module's name */
- DEFAULT_DLFLAGS, /* dlopen flags */
- 0, /* exported functions */
- mod_params, /* param exports */
- 0, /* exported statistics */
- 0, /* MI Functions */
- 0, /* pseudo-variables */
- mod_procs, /* extra processes */
- mod_init, /* module initialization function */
- 0, /* reply processing function */
- mod_destroy, /* Destroy function */
- mod_child_init /* per-child init function */
-};
#endif
Module: sip-router
Branch: master
Commit: 41e163ccd7ea6b52886e67928d453f454a239208
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=41e163c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Jan 28 09:16:05 2011 +0100
snmpstats: start the agentx process
---
modules_k/snmpstats/snmpstats.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/modules_k/snmpstats/snmpstats.c b/modules_k/snmpstats/snmpstats.c
index 9e52c03..248e693 100644
--- a/modules_k/snmpstats/snmpstats.c
+++ b/modules_k/snmpstats/snmpstats.c
@@ -266,6 +266,9 @@ static int mod_init(void)
/* Register the alarm checking function to run periodically */
register_timer(run_alarm_check, 0, ALARM_AGENT_FREQUENCY_IN_SECONDS);
+ /* add space for one extra process */
+ register_procs(1);
+
return 0;
}
@@ -275,11 +278,21 @@ static int mod_init(void)
* process, and register a handler for any state changes of our child. */
static int mod_child_init(int rank)
{
+ int pid;
+
/* We only want to setup a single process, under the main attendant. */
if (rank != PROC_MAIN) {
return 0;
}
+ pid=fork_process(PROC_NOCHLDINIT, "SNMP AgentX", 1);
+ if (pid<0)
+ return -1; /* error */
+ if(pid==0){
+ /* child */
+ agentx_child(1);
+ }
+
/* Spawn a child that will check the system up time. */
spawn_sysUpTime_child();