On 5 April 2012 17:32, Ramakrishnan Sreenivasamallan <ramakrishnan.sreeniva...@gmail.com> wrote: > I am implementing a MIB module as a Agentx sub-agent. Inside my sub-agent > code, I need to set another OID. After searching in forum it seems to me > that I need to use snmp_open() and netsnmp_query_set() functions to open a > connection to main agent. It would be great if somebody can post an example > of how to use these APIs to open a connection to main agent and set an > object from sub-agent code.
In this situation, the subagent is essentially acting in the same way as the command-line tools. The fact that it's talking to the same master agent is irrelevant here - you're opening a completely separate "client" connection, that just happens to be to the same process. So the code for opening a connection is the same as that from any other client application. See the main() method of (e.g.) apps/snmpset.c for details. That code also constructs the SET PDU (and calls 'snmp_synch_response()') directly, rather than via the netsnmp_query_set() API. If you want to use this API instead, then you'd build the varbind list using snmp_varlist_add_variable() rather than snmp_pdu_add_variable() - but the idea is essentially the same, (In fact, snmp_pdu_add_variable actually invokes snmp_varlist_add_variable anyway) Dave ------------------------------------------------------------------------------ Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders