Browse Source

snmpstats Add tcpasync and tcpmaxconns

This is to test if I can reach core configuration settings for TCP. Tests prove that it's
possible. Will go ahead and add other settings as well.

One question is if we should allow changing these variables in SNMP, like we do
over the RPC interface or selects. Let's think about that.
Olle E. Johansson 12 years ago
parent
commit
e1dc02d523

+ 75 - 0
modules/snmpstats/kamailioNet.c

@@ -42,6 +42,7 @@
 #include "utilities.h"
 #include "../../lib/kcore/statistics.h"
 #include "../../globals.h"
+#include "../../tcp_options.h"
 
 /*
  * Note: this file originally auto-generated by mib2c using
@@ -61,6 +62,8 @@ init_kamailioNet(void)
     const oid kamailioNetTcpConnPassiveOpen_oid[] = { 1,3,6,1,4,1,34352,3,1,3,1,4,1,2,6 };
     const oid kamailioNetTcpConnReject_oid[] = { 1,3,6,1,4,1,34352,3,1,3,1,4,1,2,8 };
     const oid kamailioNetTcpEnabled_oid[] = { 1,3,6,1,4,1,34352,3,1,3,1,4,1,3,1 };
+    const oid kamailioNetTcpMaxConns_oid[] = { 1,3,6,1,4,1,34352,3,1,3,1,4,1,3,2 };
+    const oid kamailioNetTcpAsync_oid[] = { 1,3,6,1,4,1,34352,3,1,3,1,4,1,3,3 };
 
   DEBUGMSGTL(("kamailioNet", "Initializing\n"));
 
@@ -104,6 +107,16 @@ init_kamailioNet(void)
                                kamailioNetTcpEnabled_oid, OID_LENGTH(kamailioNetTcpEnabled_oid),
                                HANDLER_CAN_RONLY
         ));
+    netsnmp_register_scalar(
+        netsnmp_create_handler_registration("kamailioNetTcpMaxConns", handle_kamailioNetTcpMaxConns,
+                               kamailioNetTcpMaxConns_oid, OID_LENGTH(kamailioNetTcpMaxConns_oid),
+                               HANDLER_CAN_RONLY
+        ));
+    netsnmp_register_scalar(
+        netsnmp_create_handler_registration("kamailioNetTcpAsync", handle_kamailioNetTcpAsync,
+                               kamailioNetTcpAsync_oid, OID_LENGTH(kamailioNetTcpAsync_oid),
+                               HANDLER_CAN_RONLY
+        ));
 }
 
 #ifdef SKREP
@@ -325,3 +338,65 @@ handle_kamailioNetTcpEnabled(netsnmp_mib_handler *handler,
 
     return SNMP_ERR_NOERROR;
 }
+
+int
+handle_kamailioNetTcpMaxConns(netsnmp_mib_handler *handler,
+                          netsnmp_handler_registration *reginfo,
+                          netsnmp_agent_request_info   *reqinfo,
+                          netsnmp_request_info         *requests)
+{
+    struct cfg_group_tcp t;
+    unsigned int maxconn;
+
+    tcp_options_get(&t);
+    maxconn = t.max_connections;
+
+    switch(reqinfo->mode) {
+
+        case MODE_GET:
+            snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
+			 (u_char *) &maxconn, sizeof(int));
+            break;
+
+
+        default:
+            /* we should never get here, so this is a really bad error */
+            snmp_log(LOG_ERR, "unknown mode (%d) in handle_kamailioNetTcpMaxConns\n", reqinfo->mode );
+            return SNMP_ERR_GENERR;
+    }
+
+    return SNMP_ERR_NOERROR;
+}
+int
+handle_kamailioNetTcpAsync(netsnmp_mib_handler *handler,
+                          netsnmp_handler_registration *reginfo,
+                          netsnmp_agent_request_info   *reqinfo,
+                          netsnmp_request_info         *requests)
+{
+    struct cfg_group_tcp t;
+    unsigned int value;
+
+    tcp_options_get(&t);
+    value = t.async;
+    /* We are never called for a GETNEXT if it's registered as a
+       "instance", as it's "magically" handled for us.  */
+
+    /* a instance handler also only hands us one request at a time, so
+       we don't need to loop over a list of requests; we'll only get one. */
+    
+    switch(reqinfo->mode) {
+
+        case MODE_GET:
+            snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
+			 (u_char *) &value, sizeof(int));
+            break;
+
+
+        default:
+            /* we should never get here, so this is a really bad error */
+            snmp_log(LOG_ERR, "unknown mode (%d) in handle_kamailioNetTcpAsync\n", reqinfo->mode );
+            return SNMP_ERR_GENERR;
+    }
+
+    return SNMP_ERR_NOERROR;
+}

+ 2 - 0
modules/snmpstats/kamailioNet.h

@@ -15,5 +15,7 @@ Netsnmp_Node_Handler handle_kamailioNetTcpConnOpened;
 Netsnmp_Node_Handler handle_kamailioNetTcpConnPassiveOpen;
 Netsnmp_Node_Handler handle_kamailioNetTcpConnReject;
 Netsnmp_Node_Handler handle_kamailioNetTcpEnabled;
+Netsnmp_Node_Handler handle_kamailioNetTcpMaxConns;
+Netsnmp_Node_Handler handle_kamailioNetTcpAsync;
 
 #endif /* KAMAILIONET_H */

+ 40 - 3
modules/snmpstats/mibs/KAMAILIO-MIB

@@ -193,7 +193,6 @@ KAMAILIO-MIB DEFINITIONS ::= BEGIN
         "Architecture Kamailio is compiled for"
         ::= { kamailioSrvConfig 4 }
 
-
     kamailioSrvCnfVerOs	OBJECT-TYPE
         SYNTAX DisplayString
         MAX-ACCESS  read-only
@@ -202,7 +201,6 @@ KAMAILIO-MIB DEFINITIONS ::= BEGIN
         "Operating System Kamailio is compiled for"
         ::= { kamailioSrvConfig 5 }
 
-
     kamailioSrvCnfVerId	OBJECT-TYPE
         SYNTAX DisplayString
         MAX-ACCESS  read-only
@@ -211,7 +209,6 @@ KAMAILIO-MIB DEFINITIONS ::= BEGIN
         "Kamailio Version ID"
         ::= { kamailioSrvConfig 6 }
 
-
     kamailioSrvCnfVerCompTime OBJECT-TYPE
         SYNTAX DisplayString
         MAX-ACCESS  read-only
@@ -316,6 +313,46 @@ KAMAILIO-MIB DEFINITIONS ::= BEGIN
         "True if TCP is enabled in this server."
         ::= { kamailioNetTcpConfig 1 }
 
+    kamailioNetTcpMaxConns OBJECT-TYPE
+        SYNTAX  Integer32
+        MAX-ACCESS  read-only
+        STATUS current
+        DESCRIPTION 
+        "Maximum number of TCP connections (configurable)"
+        ::= { kamailioNetTcpConfig 2 }
+
+    kamailioNetTcpAsync OBJECT-TYPE
+        SYNTAX  TruthValue
+        MAX-ACCESS  read-only
+        STATUS current
+        DESCRIPTION 
+        "True if TCP Async is enabled in this server."
+        ::= { kamailioNetTcpConfig 3 }
+
+	---	connect_timeout: 10
+	---	send_timeout: 10
+	---	connection_lifetime: 120
+	---	max_connections(soft): 2048
+	---	max_tls_connections(soft): 2048
+	---	no_connect: 0
+	---	fd_cache: 1
+	---	async: 1
+	---	connect_wait: 1
+	---	conn_wq_max: 32768
+	---	wq_max: 10485760
+	---	defer_accept: 0
+	---	delayed_ack: 0
+	---	syncnt: 0
+	---	linger2: 0
+	---	keepalive: 1
+	---	keepidle: 0
+	---	keepintvl: 0
+	---	keepcnt: 0
+	---	crlf_ping: 1
+	---	accept_aliases: 0
+	---	alias_flags: 1
+	---	new_conn_alias_flags: 2
+
 --
 -- TCP connection statistic objects
 --