|
@@ -0,0 +1,126 @@
|
|
|
+/*
|
|
|
+ *
|
|
|
+ * SNMPStats Module
|
|
|
+ * Copyright (C) 2006 SOMA Networks, INC.
|
|
|
+ * Written by: Jeffrey Magder ([email protected])
|
|
|
+ *
|
|
|
+ * Kamailio Server core objects addition
|
|
|
+ * Copyright (C) 2013 Edvina AB, Sollentuna, Sweden
|
|
|
+ * Written by Olle E. Johansson
|
|
|
+ *
|
|
|
+ * This file is part of Kamailio, a free SIP server.
|
|
|
+ *
|
|
|
+ * Kamailio is free software; you can redistribute it and/or modify it
|
|
|
+ * under the terms of the GNU General Public License as published by
|
|
|
+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
+ * (at your option) any later version
|
|
|
+ *
|
|
|
+ * Kamailio is distributed in the hope that it will be useful, but
|
|
|
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
+ * General Public License for more details.
|
|
|
+ *
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
+ * along with this program; if not, write to the Free Software
|
|
|
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
+ * USA
|
|
|
+ *
|
|
|
+ * History:
|
|
|
+ * --------
|
|
|
+ * 2013-03-24 initial version (oej)
|
|
|
+ *
|
|
|
+ * Note: this file originally auto-generated by mib2c
|
|
|
+ *
|
|
|
+ */
|
|
|
+
|
|
|
+#include <net-snmp/net-snmp-config.h>
|
|
|
+#include <net-snmp/net-snmp-includes.h>
|
|
|
+#include <net-snmp/agent/net-snmp-agent-includes.h>
|
|
|
+#include "kamailioServer.h"
|
|
|
+
|
|
|
+#include "snmpstats_globals.h"
|
|
|
+#include "utilities.h"
|
|
|
+#include "../../lib/kcore/statistics.h"
|
|
|
+
|
|
|
+/** Initializes the kamailioServer module */
|
|
|
+void
|
|
|
+init_kamailioServer(void)
|
|
|
+{
|
|
|
+ const oid kamailioSrvMaxMemory_oid[] = { 1,3,6,1,4,1,34352,3,1,3,1,1,1,1 };
|
|
|
+ const oid kamailioSrvFreeMemory_oid[] = { 1,3,6,1,4,1,34352,3,1,3,1,1,1,2 };
|
|
|
+
|
|
|
+ DEBUGMSGTL(("kamailioServer", "Initializing\n"));
|
|
|
+ LM_DBG("initializing Kamailio Server OID's X\n");
|
|
|
+
|
|
|
+ netsnmp_register_scalar(
|
|
|
+ netsnmp_create_handler_registration("kamailioSrvMaxMemory", handle_kamailioSrvMaxMemory,
|
|
|
+ kamailioSrvMaxMemory_oid, OID_LENGTH(kamailioSrvMaxMemory_oid),
|
|
|
+ HANDLER_CAN_RONLY
|
|
|
+ ));
|
|
|
+ netsnmp_register_scalar(
|
|
|
+ netsnmp_create_handler_registration("kamailioSrvFreeMemory", handle_kamailioSrvFreeMemory,
|
|
|
+ kamailioSrvFreeMemory_oid, OID_LENGTH(kamailioSrvFreeMemory_oid),
|
|
|
+ HANDLER_CAN_RONLY
|
|
|
+ ));
|
|
|
+}
|
|
|
+
|
|
|
+int
|
|
|
+handle_kamailioSrvMaxMemory(netsnmp_mib_handler *handler,
|
|
|
+ netsnmp_handler_registration *reginfo,
|
|
|
+ netsnmp_agent_request_info *reqinfo,
|
|
|
+ netsnmp_request_info *requests)
|
|
|
+{
|
|
|
+ /* 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. */
|
|
|
+
|
|
|
+ int maxmemory = get_statistic("total_size");
|
|
|
+
|
|
|
+ switch(reqinfo->mode) {
|
|
|
+
|
|
|
+ case MODE_GET:
|
|
|
+ snmp_set_var_typed_value(requests->requestvb, ASN_GAUGE,
|
|
|
+ (u_char *) &maxmemory, 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_kamailioSrvMaxMemory\n", reqinfo->mode );
|
|
|
+ return SNMP_ERR_GENERR;
|
|
|
+ }
|
|
|
+
|
|
|
+ return SNMP_ERR_NOERROR;
|
|
|
+}
|
|
|
+int
|
|
|
+handle_kamailioSrvFreeMemory(netsnmp_mib_handler *handler,
|
|
|
+ netsnmp_handler_registration *reginfo,
|
|
|
+ netsnmp_agent_request_info *reqinfo,
|
|
|
+ netsnmp_request_info *requests)
|
|
|
+{
|
|
|
+ int freememory = get_statistic("free_size");
|
|
|
+
|
|
|
+ /* 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_GAUGE,
|
|
|
+ (u_char *) &freememory, 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_kamailioSrvFreeMemory\n", reqinfo->mode );
|
|
|
+ return SNMP_ERR_GENERR;
|
|
|
+ }
|
|
|
+
|
|
|
+ return SNMP_ERR_NOERROR;
|
|
|
+}
|