hello,

i am trying to develop net-snmp agent in my existing application P1.

i am using a separate thread for the sub-Agent in my application that uses
below function.

int start_snmp_agent()
{
  int agentx_subagent=1; /* change this if you want to be a SNMP master agent */
  int background = 0; /* change this if you want to run in the background */
  int syslog = 0; /* change this if you want to use syslog */

  /* print log errors to syslog or stderr */
  if (syslog)
    snmp_enable_calllog();
  else
    snmp_enable_stderrlog();

  /* we're an agentx subagent? */
  if (agentx_subagent) {
    /* make us a agentx client. */
    netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
  }

  /* run in background, if requested */
  if (background && netsnmp_daemonize(1, !syslog))
      exit(1);

  /* initialize tcpip, if necessary */
  SOCK_STARTUP;

  /* initialize the agent library */
  init_agent("example-demon");

  /* initialize mib code here */

  /* mib code: init_nstAgentSubagentObject from nstAgentSubagentObject.C */
  init_nstAgentSubagentObject();

  /* initialize vacm/usm access control  */
  if (!agentx_subagent) {
      init_vacm_vars();
      init_usmUser();
  }

  /* example-demon will be used to read example-demon.conf files. */
  init_snmp("p1");

  /* If we're going to be a snmp master agent, initial the ports */
  if (!agentx_subagent)
    init_master_agent();  /* open the port to listen on (defaults to udp:161) */

  /* In case we recevie a request to stop (kill -TERM or kill -INT) */
  keep_running = 1;
  signal(SIGTERM, stop_server);
  signal(SIGINT, stop_server);

  snmp_log(LOG_INFO,"p1 is up and running.\n");

  while(keep_running) {
    agent_check_and_process(1);
  }

  /* at shutdown time */
  snmp_shutdown("p1");
  SOCK_CLEANUP;

  return 0;
}


when i am starting my existing application p1 that stops executing when it
starts the sub agent code(this code).

can you please help me how i can develop sub agent that can be embeded in
existing application.

Regards
Ashish

On Thu, Jan 14, 2010 at 1:38 PM, Dave Shield <d.t.shi...@liverpool.ac.uk>wrote:

> 2010/1/14 Ashish vashishtha <ashish.vashish...@gmail.com>:
> > if i make my process p1 as a net snmp subagent using agentx than will the
> > snmp master agent(SNMPD) will forward all the incoming requests to P1
>
> No.   Not necessarily.
>
> > (as there can be more than one sub-Agent)?
>
> Each subagent will register with the master agent,
> specifying the OID range(s) that it implements.
> The master agent then uses this information to pass
> each requested varbind to the appropriate subagent.
>
>
> > is it possible to filter incoming requests from the snmpd to
> > the p1 based on the range of the OIDs ?
> > if yes than how this filtering can be done.
>
> That is the natural operation of AgentX.
> Please see the AgentX specs, or any recent SNMP book for details.
>
> Dave
>



-- 
Regards
Ashish Vashishtha
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to