0

I use net-snmp. I try to add my own mibs (no need in handler, just a MIB that i can get and set by snmp call), so i followed the scalar example. In order to add my own mibs i defined them in the mib file and create an agent extension.(see below).

It work, so i have now an integer MIB. Now i want to add string mib, so i define the MIB , but i dont find a register API for string, like i have for the int - netsnmp_register_int_instance. I look in the includes file , but dosnt found matching one.

agent:

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "monitor.h"


static int int_init = 0;  /* default value */


void init_monitor(void)
{

    oid  open_connections_count_oid[] =
        { 1, 3, 6, 1, 4, 1, 8075, 1, 0 };

    netsnmp_register_int_instance("open_connections_count",
                                  open_connections_count_oid,
                                  OID_LENGTH(open_connections_count_oid),
                                  &int_init, NULL);

}
Avihai Marchiano
  • 592
  • 3
  • 15
  • 32

1 Answers1

0

I dont know if this is the right way, but it work.

static char errors_value[MY_MAX_LEN];
void init_monitor_snmp_agent(void) {
    const oid errors_oid[] = { 1, 3, 6, 1, 4, 1, 8075, 10 };//In this we dont add the 0 at the end
    strcpy(errors_value, "");
    netsnmp_register_watched_scalar(
            netsnmp_create_handler_registration("open_connections_list", NULL,
                    errors_oid, OID_LENGTH(errors_oid),
                    HANDLER_CAN_RWRITE),
            netsnmp_create_watcher_info(&errors_value, MY_MAX_LEN,
                    ASN_OCTET_STR, WATCHER_MAX_SIZE));
}
Avihai Marchiano
  • 592
  • 3
  • 15
  • 32