Module: sip-router
Branch: master
Commit: e1dc02d523867fc9934e862397e6da6b256c7b1b
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e1dc02d…
Author: Olle E. Johansson <oej(a)edvina.net>
Committer: Olle E. Johansson <oej(a)edvina.net>
Date: Tue Mar 26 22:16:03 2013 +0100
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.
---
modules/snmpstats/kamailioNet.c | 75 +++++++++++++++++++++++++++++++++++
modules/snmpstats/kamailioNet.h | 2 +
modules/snmpstats/mibs/KAMAILIO-MIB | 43 ++++++++++++++++++-
3 files changed, 117 insertions(+), 3 deletions(-)
diff --git a/modules/snmpstats/kamailioNet.c b/modules/snmpstats/kamailioNet.c
index 535077d..efac0b9 100644
--- a/modules/snmpstats/kamailioNet.c
+++ b/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;
+}
diff --git a/modules/snmpstats/kamailioNet.h b/modules/snmpstats/kamailioNet.h
index 96ceedc..f037b3b 100644
--- a/modules/snmpstats/kamailioNet.h
+++ b/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 */
diff --git a/modules/snmpstats/mibs/KAMAILIO-MIB b/modules/snmpstats/mibs/KAMAILIO-MIB
index a6901e5..96bc9e9 100644
--- a/modules/snmpstats/mibs/KAMAILIO-MIB
+++ b/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
--