Hi all,

I am using NetSNMP version 5.0.9 for developing a sub agent on solaris.

 

The sub agent periodically needs to check the value (threshold) of a specific OID.  I have gone through the getsnmp code and followed the same approach.

The problem is currently I am not able to get the community string, defined in snmp.conf. ( master configuration file)

Tried using “netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,NETSNMP_DS_LIB_COMMUNITY); but it dumps core.

The above function is called in init function of sub agent, which is called after - init_snmp() and init_agent() in main agent file.

So the calling sequence is

a) Init_agent()

b) Init_snmp()

c) Init_subagent() - -> GetOidVal()

 

Also is this the best way to get value for a specific OID from master agent?

 

Expecting a reply…

 

Thanks in advance,

George

 

 

NB: Here is the code snippet. ==========================================

GetOidVal() {

    snmp_sess_init(&session);

    char* comm_str = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,NETSNMP_DS_LIB_COMMUNITY);

    session.version = SNMP_VERSION_1;

    session.community  = (unsigned char*) comm._str;

    session.community_len = strlen( session.community );

    session.peername = "localhost";

    sess_handle = snmp_open(&session);

 

    pdu = snmp_pdu_create(SNMP_MSG_GET);

    snmp_add_null_var( pdu, chkOid, oid_len);

 

    status = snmp_synch_response(sess_handle, pdu, &response);

   if (response->variables) && response->errstat == SNMPERR_SUCCESS  && response->variables->val.integer)

    read_value()

}

 

============================================

 

 

Reply via email to