예제 #1
0
void
init_agent (const char *app)
{
  /* get current time (ie, the time the agent started) */
  gettimeofday(&starttime, NULL);
  starttime.tv_sec--;
  starttime.tv_usec += 1000000L;

  /* we handle alarm signals ourselves in the select loop */
  ds_set_boolean(DS_LIBRARY_ID, DS_LIB_ALARM_DONT_USE_SIG, 1);

#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
  usm_set_reportErrorOnUnknownID(1);
#endif

#ifdef CAN_USE_NLIST
  init_kmem("/dev/kmem");
#endif

  setup_tree();

  init_agent_read_config(app);

#ifdef TESTING
  auto_nlist_print_tree(-2, 0);
#endif

  /* initialize agentx subagent if necessary. */
#ifdef USING_AGENTX_SUBAGENT_MODULE
  if(ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE) == SUB_AGENT)
      subagent_pre_init();
#endif

}  /* end init_agent() */
예제 #2
0
파일: snmp_vars.c 프로젝트: DYFeng/infinidb
/**
 * Initialize the agent.  Calls into init_agent_read_config to set tha app's
 * configuration file in the appropriate default storage space,
 *  NETSNMP_DS_LIB_APPTYPE.  Need to call init_agent before calling init_snmp.
 *
 * @param app the configuration file to be read in, gets stored in default
 *        storage
 *
 * @return Returns non-zero on failure and zero on success.
 *
 * @see init_snmp
 */
int
init_agent(const char *app)
{
    int             r = 0;

    if(++done_init_agent > 1) {
        snmp_log(LOG_WARNING, "ignoring extra call to init_agent (%d)\n", 
                 done_init_agent);
        return r;
    }

    /*
     * get current time (ie, the time the agent started) 
     */
    gettimeofday(&starttime, NULL);
    starttime.tv_sec--;
    starttime.tv_usec += 1000000L;

    /*
     * we handle alarm signals ourselves in the select loop 
     */
    netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, 
			   NETSNMP_DS_LIB_ALARM_DONT_USE_SIG, 1);

#ifdef CAN_USE_NLIST
    init_kmem("/dev/kmem");
#endif

    setup_tree();

    init_agent_read_config(app);

#ifdef TESTING
    auto_nlist_print_tree(-2, 0);
#endif

    _init_agent_callback_transport();
    
    netsnmp_init_helpers();
    init_traps();
    netsnmp_container_init_list();

    /*
     * initialize agentx subagent if necessary. 
     */
#ifdef USING_AGENTX_SUBAGENT_MODULE
    if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, 
			       NETSNMP_DS_AGENT_ROLE) == SUB_AGENT) {
        r = subagent_pre_init();
        init_subagent();
    }
#endif

    /*
     * Register configuration tokens from transport modules.  
     */
#ifdef SNMP_TRANSPORT_UDP_DOMAIN
    netsnmp_udp_agent_config_tokens_register();
#endif
#ifdef SNMP_TRANSPORT_UDPIPV6_DOMAIN
    netsnmp_udp6_agent_config_tokens_register();
#endif
#ifdef SNMP_TRANSPORT_UNIX_DOMAIN
    netsnmp_unix_agent_config_tokens_register();
#endif

#ifdef NETSNMP_EMBEDDED_PERL
    init_perl();
#endif

#  include "agent_module_inits.h"

    return r;
}                               /* end init_agent() */