2
0
Эх сурвалжийг харах

snmpstats: control exporting registrar records

- exporting of large location database may result in out of shared
  memory, as well as when the records are not pulled - might be the case
  of out of memory messages reported by Klaus Darilion
- new parameter export_registrar was added to enable/disable location
  records export (off by default)
- fixed missing exporting the counter with all processed dialogs
  (discussion from March 2011 with Stefan Tiedje)
Daniel-Constantin Mierla 14 жил өмнө
parent
commit
0696af54da

+ 24 - 7
modules_k/snmpstats/README

@@ -8,7 +8,7 @@ Edited by
 
 
 Jeffrey Magder
 Jeffrey Magder
 
 
-   Copyright © 2006 SOMA Networks, Inc.
+   Copyright © 2006 SOMA Networks, Inc.
      __________________________________________________________________
      __________________________________________________________________
 
 
    Table of Contents
    Table of Contents
@@ -40,6 +40,7 @@ Jeffrey Magder
               4.5. dlg_major_threshold (Integer)
               4.5. dlg_major_threshold (Integer)
               4.6. snmpgetPath (String)
               4.6. snmpgetPath (String)
               4.7. snmpCommunity (String)
               4.7. snmpCommunity (String)
+              4.8. export_registrar (int)
 
 
         5. Functions
         5. Functions
         6. Installation and Running
         6. Installation and Running
@@ -64,6 +65,7 @@ Jeffrey Magder
    1.5. Setting the dlg_major_threshold parameter
    1.5. Setting the dlg_major_threshold parameter
    1.6. Setting the snmpgetPath parameter
    1.6. Setting the snmpgetPath parameter
    1.7. Setting the snmpCommunity parameter
    1.7. Setting the snmpCommunity parameter
+   1.8. Setting the export_registrar parameter
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
 
 
@@ -94,6 +96,7 @@ Chapter 1. Admin Guide
         4.5. dlg_major_threshold (Integer)
         4.5. dlg_major_threshold (Integer)
         4.6. snmpgetPath (String)
         4.6. snmpgetPath (String)
         4.7. snmpCommunity (String)
         4.7. snmpCommunity (String)
+        4.8. export_registrar (int)
 
 
    5. Functions
    5. Functions
    6. Installation and Running
    6. Installation and Running
@@ -275,6 +278,7 @@ Chapter 1. Admin Guide
    4.5. dlg_major_threshold (Integer)
    4.5. dlg_major_threshold (Integer)
    4.6. snmpgetPath (String)
    4.6. snmpgetPath (String)
    4.7. snmpCommunity (String)
    4.7. snmpCommunity (String)
+   4.8. export_registrar (int)
 
 
 4.1. sipEntityType (String)
 4.1. sipEntityType (String)
 
 
@@ -367,7 +371,7 @@ modparam("snmpstats", "MsgQueueMajorThreshold", 5000)
    the master agent. You can use this parameter to set the path to your
    the master agent. You can use this parameter to set the path to your
    instance of NetSNMP's snmpget program.
    instance of NetSNMP's snmpget program.
 
 
-   Default value is “/usr/local/bin/�.
+   Default value is "/usr/local/bin/".
 
 
    Example 1.6. Setting the snmpgetPath parameter
    Example 1.6. Setting the snmpgetPath parameter
 ...
 ...
@@ -381,13 +385,26 @@ modparam("snmpstats", "snmpgetPath",     "/my/custom/path/")
    the master agent. If you have defined a custom community string for the
    the master agent. If you have defined a custom community string for the
    snmp daemon, you need to specify it with this parameter.
    snmp daemon, you need to specify it with this parameter.
 
 
-   Default value is “public�.
+   Default value is "public".
 
 
    Example 1.7. Setting the snmpCommunity parameter
    Example 1.7. Setting the snmpCommunity parameter
 ...
 ...
 modparam("snmpstats", "snmpCommunity", "customCommunityString")
 modparam("snmpstats", "snmpCommunity", "customCommunityString")
 ...
 ...
 
 
+4.8. export_registrar (int)
+
+   The SNMPStats module will export registrar (usrloc) records if this
+   parameter is set to 1. This will result in more memory usage and bigger
+   exporter structure.
+
+   Default value is "0" (don't export).
+
+   Example 1.8. Setting the export_registrar parameter
+...
+modparam("snmpstats", "export_registrar", 1)
+...
+
 5. Functions
 5. Functions
 
 
    Currently, there are no exported functions.
    Currently, there are no exported functions.
@@ -406,7 +423,7 @@ modparam("snmpstats", "snmpCommunity", "customCommunityString")
    There are several things that need to be done to get the SNMPStats
    There are several things that need to be done to get the SNMPStats
    module compiled and up and running.
    module compiled and up and running.
 
 
-6.1.  Compiling the SNMPStats Module
+6.1. Compiling the SNMPStats Module
 
 
    In order for the SNMPStats module to compile, you will need at least
    In order for the SNMPStats module to compile, you will need at least
    version 5.3 of the NetSNMP source code. The source can be found at:
    version 5.3 of the NetSNMP source code. The source can be found at:
@@ -428,7 +445,7 @@ modparam("snmpstats", "snmpCommunity", "customCommunityString")
    recommended you install NetSNMP from source to avoid bringing in
    recommended you install NetSNMP from source to avoid bringing in
    excessive dependencies to the SNMPStats module.
    excessive dependencies to the SNMPStats module.
 
 
-6.2.  Configuring NetSNMP to allow connections from the SNMPStats module.
+6.2. Configuring NetSNMP to allow connections from the SNMPStats module.
 
 
    The SNMPStats module will communicate with the NetSNMP Master Agent.
    The SNMPStats module will communicate with the NetSNMP Master Agent.
    This communication happens over a protocol known as AgentX. This means
    This communication happens over a protocol known as AgentX. This means
@@ -460,7 +477,7 @@ modparam("snmpstats", "snmpCommunity", "customCommunityString")
    This tells NetSNMP to act as a master agent, listening on the localhost
    This tells NetSNMP to act as a master agent, listening on the localhost
    UDP interface at port 705.
    UDP interface at port 705.
 
 
-6.3.  Configuring the SNMPStats module for communication with a Master Agent
+6.3. Configuring the SNMPStats module for communication with a Master Agent
 
 
    The previous section explained how to set up a NetSNMP master agent to
    The previous section explained how to set up a NetSNMP master agent to
    accept AgentX connections. We now need to tell the SNMPStats module how
    accept AgentX connections. We now need to tell the SNMPStats module how
@@ -480,7 +497,7 @@ modparam("snmpstats", "snmpCommunity", "customCommunityString")
    be present on the same machine as OpenSER. localhost could be replaced
    be present on the same machine as OpenSER. localhost could be replaced
    with any other machine.
    with any other machine.
 
 
-6.4.  Testing for a proper Configuration
+6.4. Testing for a proper Configuration
 
 
    As a quick test to make sure that the SNMPStats module sub-agent can
    As a quick test to make sure that the SNMPStats module sub-agent can
    succesfully connect to the NetSNMP Master agent, start snmpd with the
    succesfully connect to the NetSNMP Master agent, start snmpd with the

+ 25 - 0
modules_k/snmpstats/doc/snmpstats_admin.xml

@@ -421,6 +421,31 @@ modparam("snmpstats", "snmpCommunity", "customCommunityString")
 		</example>
 		</example>
 	</section>
 	</section>
 
 
+	<section>
+		<title><varname>export_registrar</varname> (int)</title>
+
+		<para>
+		The SNMPStats module will export registrar (usrloc) records if
+		this parameter is set to 1. This will result in more memory usage
+		and bigger exporter structure.
+		</para>
+
+		<para>
+		<emphasis>
+			Default value is <quote>0</quote> (don't export).
+		</emphasis>
+		</para>
+
+		<example>
+		<title>Setting the <varname>export_registrar</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("snmpstats", "export_registrar", 1)
+...
+		</programlisting>
+		</example>
+	</section>
+
 	</section>
 	</section>
 	<section>
 	<section>
 	<title>Functions</title>
 	<title>Functions</title>

+ 12 - 1
modules_k/snmpstats/mibs/OPENSER-MIB

@@ -399,6 +399,16 @@ OPENSER-MIB DEFINITIONS ::= BEGIN
              -1 indicates the value is not configured, and alarms will never be 
              -1 indicates the value is not configured, and alarms will never be 
              set, and the usage state will never be reported as 'busy'."
              set, and the usage state will never be reported as 'busy'."
         ::= { openserDialogStats 6 }
         ::= { openserDialogStats 6 }
+
+    openserTotalNumDialogSetups     OBJECT-TYPE
+        SYNTAX      Counter32
+        MAX-ACCESS  read-only
+        STATUS      current
+        DESCRIPTION
+            "The total number of calls (answered and failed)."
+        ::= { openserDialogStats 7 }
+
+
 --
 --
 -- Dialog State
 -- Dialog State
 --
 --
@@ -601,7 +611,8 @@ OPENSER-MIB DEFINITIONS ::= BEGIN
             openserCurNumDialogsInSetup,
             openserCurNumDialogsInSetup,
             openserTotalNumFailedDialogSetups,
             openserTotalNumFailedDialogSetups,
             openserDialogLimitMinorThreshold,
             openserDialogLimitMinorThreshold,
-            openserDialogLimitMajorThreshold           
+            openserDialogLimitMajorThreshold,
+            openserTotalNumDialogSetups
         }
         }
         STATUS  current
         STATUS  current
         DESCRIPTION
         DESCRIPTION

+ 28 - 0
modules_k/snmpstats/snmpObjects.c

@@ -94,6 +94,9 @@ void init_openserObjects(void)
 	static oid openserDialogLimitMajorThreshold_oid[]  = 
 	static oid openserDialogLimitMajorThreshold_oid[]  = 
 		{ OPENSER_OID,3,1,3,1,3,2,6 };
 		{ OPENSER_OID,3,1,3,1,3,2,6 };
 
 
+	static oid openserTotalNumDialogSetups_oid[] =
+		{ OPENSER_OID,3,1,3,1,3,2,7 };
+
 	static oid openserDialogUsageState_oid[]       = 
 	static oid openserDialogUsageState_oid[]       = 
 		{ OPENSER_OID,3,1,3,1,3,3,1 };
 		{ OPENSER_OID,3,1,3,1,3,3,1 };
 
 
@@ -217,6 +220,15 @@ void init_openserObjects(void)
 			HANDLER_CAN_RONLY)
 			HANDLER_CAN_RONLY)
 		);
 		);
 
 
+	netsnmp_register_scalar(
+		netsnmp_create_handler_registration(
+			"openserTotalNumDialogSetups",
+		handle_openserTotalNumDialogSetups,
+		openserTotalNumDialogSetups_oid,
+		OID_LENGTH(openserTotalNumDialogSetups_oid),
+		HANDLER_CAN_RONLY)
+		);
+
 	netsnmp_register_scalar(
 	netsnmp_register_scalar(
 		netsnmp_create_handler_registration(
 		netsnmp_create_handler_registration(
 			"openserDialogUsageState", 
 			"openserDialogUsageState", 
@@ -467,6 +479,22 @@ int handle_openserTotalNumFailedDialogSetups(netsnmp_mib_handler *handler,
 	return SNMP_ERR_GENERR;
 	return SNMP_ERR_GENERR;
 }
 }
 
 
+int handle_openserTotalNumDialogSetups(netsnmp_mib_handler *handler,
+		netsnmp_handler_registration *reginfo,
+		netsnmp_agent_request_info   *reqinfo,
+		netsnmp_request_info         *requests)
+{
+	int result = get_statistic("processed_dialogs");
+
+	if (reqinfo->mode == MODE_GET) {
+		snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER,
+			(u_char *) &result, sizeof(int));
+		return SNMP_ERR_NOERROR;
+	}
+
+	return SNMP_ERR_GENERR;
+}
+
 int handle_openserDialogLimitMinorThreshold(netsnmp_mib_handler *handler,
 int handle_openserDialogLimitMinorThreshold(netsnmp_mib_handler *handler,
 		netsnmp_handler_registration *reginfo,
 		netsnmp_handler_registration *reginfo,
 		netsnmp_agent_request_info   *reqinfo,
 		netsnmp_agent_request_info   *reqinfo,

+ 1 - 0
modules_k/snmpstats/snmpObjects.h

@@ -57,6 +57,7 @@ Netsnmp_Node_Handler handle_openserCurNumDialogsInSetup;
 Netsnmp_Node_Handler handle_openserTotalNumFailedDialogSetups;
 Netsnmp_Node_Handler handle_openserTotalNumFailedDialogSetups;
 Netsnmp_Node_Handler handle_openserDialogLimitMinorThreshold;
 Netsnmp_Node_Handler handle_openserDialogLimitMinorThreshold;
 Netsnmp_Node_Handler handle_openserDialogLimitMajorThreshold;
 Netsnmp_Node_Handler handle_openserDialogLimitMajorThreshold;
+Netsnmp_Node_Handler handle_openserTotalNumDialogSetups;
 Netsnmp_Node_Handler handle_openserDialogUsageState;
 Netsnmp_Node_Handler handle_openserDialogUsageState;
 Netsnmp_Node_Handler handle_openserDialogLimitAlarmStatus;
 Netsnmp_Node_Handler handle_openserDialogLimitAlarmStatus;
 Netsnmp_Node_Handler handle_openserDialogLimitMinorAlarm;
 Netsnmp_Node_Handler handle_openserDialogLimitMinorAlarm;

+ 25 - 15
modules_k/snmpstats/snmpstats.c

@@ -107,6 +107,10 @@
 /* Required in every Kamailio Module. */
 /* Required in every Kamailio Module. */
 MODULE_VERSION
 MODULE_VERSION
 
 
+/* module parameter to register for usrloc callbacks or not,
+ * in order to export registrar records (0 - don't export, 1 - export) */
+static int snmp_export_registrar = 0;
+
 /*! This is the first function to be called by Kamailio, to initialize the module.
 /*! 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
  * 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
  * return, then Kamailio would not be able to initialize any of the other
@@ -150,6 +154,10 @@ static param_export_t mod_params[] =
 			(void *)set_snmpget_path          },
 			(void *)set_snmpget_path          },
 	{ "snmpCommunity",          STR_PARAM|USE_FUNC_PARAM,
 	{ "snmpCommunity",          STR_PARAM|USE_FUNC_PARAM,
 			(void *)set_snmp_community        },
 			(void *)set_snmp_community        },
+	{ "snmpCommunity",          STR_PARAM|USE_FUNC_PARAM,
+			(void *)set_snmp_community        },
+	{ "export_registrar",       INT_PARAM,
+			&snmp_export_registrar            },
 	{ 0,0,0 }
 	{ 0,0,0 }
 };
 };
 
 
@@ -318,24 +326,26 @@ static int mod_init(void)
 	 * the database.  That load will happen if a lookup() function is come
 	 * the database.  That load will happen if a lookup() function is come
 	 * across in kamailio.cfg. */
 	 * across in kamailio.cfg. */
 
 
-	if (!registerForUSRLOCCallbacks()) 
+	if (snmp_export_registrar!=0)
 	{
 	{
-		/* Originally there were descriptive error messages here to help
-		 * the operator debug problems.  Turns out this may instead
-		 * alarm them about problems they don't need to worry about.  So
-		 * the messages are commented out for now */
+		if(!registerForUSRLOCCallbacks())
+		{
+			/* Originally there were descriptive error messages here to help
+			 * the operator debug problems.  Turns out this may instead
+			 * alarm them about problems they don't need to worry about.  So
+			 * the messages are commented out for now */
 		
 		
-		/*
-		LM_ERR("snmpstats module was unable to register callbacks" 
-						" with the usrloc module\n");
-		LM_ERR("Are you sure that the usrloc module was loaded"
-				" before the snmpstats module in ");
-		LM_ERR("kamailio.cfg?  openserSIPRegUserTable will not be "
-			   "updated.");
-		*/
-	} 
+			/*
+			LM_ERR("snmpstats module was unable to register callbacks"
+					" with the usrloc module\n");
+			LM_ERR("Are you sure that the usrloc module was loaded"
+					" before the snmpstats module in ");
+			LM_ERR("kamailio.cfg?  openserSIPRegUserTable will not be "
+				   "updated.");
+			*/
+		}
+	}
 
 
-	
 	/* Register the alarm checking function to run periodically */
 	/* Register the alarm checking function to run periodically */
 	register_timer(run_alarm_check, 0, ALARM_AGENT_FREQUENCY_IN_SECONDS);
 	register_timer(run_alarm_check, 0, ALARM_AGENT_FREQUENCY_IN_SECONDS);