Re: several sub agents on the same machine with lowest possible influence on the system

"Sebastian Fabig" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Ok, with this callback method it is working, maybe somebody else might want to use it.

int callbackHandler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo,
					netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests)
{
	char* name = "test";
	switch(reqinfo->mode)
	{
	case MODE_GET_NEXT:
	case MODE_GET:
		requests->delegated = 0;
		snmp_set_var_typed_value(requests->requestvb,
                ASN_OCTET_STR, name, strlen(name));
		break;
	default:
		break;
	}
	return SNMP_ERR_NOERROR;
}

Is there a way how I can use this callback-function for several different oids or do I have to rewrite this callbackhandlers for every oid?

What I need is the oid which the callback-handler is called for. And what happens, if several oids are requested at once? Is the callback called once for every oid or do I have to iterate through something? Do I have to iterate for example through requestvb to set the return values?

Thanks for your time.


-------- Original-Nachricht --------
> Datum: Thu, 16 Sep 2010 11:28:17 +0200
> Von: "Sebastian Fabig" <[email protected]>
> An: "Wes Hardaker" <[email protected]>, [email protected]
> Betreff: Re: several sub agents on the same machine with lowest possible	influence on the system

> Hi Wes,
> 
> thank you for your answer. Sorry, if I might not answer correctly, this is
> the first time I'm using a mailinglist.
> 
> I integrated the following lines (I simplified it a bit) into my source
> code:
> 
> static const oid s_my_registration_oid[] = { 1, 3, 6, 1, 4, 1, 1454, 3, 6,
> 1};
> static int s_examplevalue = 3;
> 
> void initAgent()
> {
> 	//this is a master agent
>         netsnmp_ds_set_boolean( NETSNMP_DS_APPLICATION_ID, 
>                                 NETSNMP_DS_AGENT_ROLE, 0);
> 	SOCK_STARTUP;
> 	
> 	debug_register_tokens("read-config");
> 	snmp_set_do_debugging(1);
> 	snmp_enable_stderrlog();
> 
> 	netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,     
>                     NETSNMP_DS_LIB_OPTIONALCONFIG, "C:\snmpd.conf");
> 
> 	init_agent("myapp");
> 	netsnmp_register_read_only_int_instance("nstAgentSubagentObject",
>                                   s_my_registration_oid,
>                                   OID_LENGTH(s_my_registration_oid),
>                                   &s_examplevalue, &callbackHandler);
> 
> 	init_mib_modules();
> 	init_snmp("pl");
> 	
> 	init_master_agent();
> 
> 	while(true) {
> 		agent_check_and_process(1);
> 	}
> 	snmp_shutdown("pl");
> 	SOCK_CLEANUP;
> }
> 
> 
> 
> My snmpd.conf looks like this:
> 
> rocommunity  public  
> syscontact  "anonym"
> 
> 
> It is working right now, I can request the syscontact - oid and all other
> standard things.
> 
> But what do I have to do to get my new oid working? I think I have to tell
> net-snmp to load my MIB-File, but how? Is there any function for this?
> 
> My second question is, if there is any possibility to register the
> rocommunity "public" without using a conf-file. Is there any function I can use
> for this or is it only possible to use it via the conf-file?
> 
> I hope anybody can help me with this, as I badly need it.
> -- 
> GRATIS: Spider-Man 1-3 sowie 300 weitere Videos!
> Jetzt freischalten! http://portal.gmx.net/de/go/maxdome
> 
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Net-snmp-users mailing list
> [email protected]
> Please see the following page to unsubscribe or change other options:
> https://lists.sourceforge.net/lists/listinfo/net-snmp-users

-- 
GRATIS: Spider-Man 1-3 sowie 300 weitere Videos!
Jetzt freischalten! http://portal.gmx.net/de/go/maxdome

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.