Hi,

I want tell you that I have find the probably solution to the problem of AgentX on Win32 (MinGW).


The main of subagent (client) needs SOCK_STARTUP macro, before the init_agent function,
for socket's initialization.



I have modified the net-snmp-config and the new file generated is :


/* generated from net-snmp-config */ #include <net-snmp/net-snmp-config.h> #ifdef HAVE_SIGNAL_H #include <signal.h> #endif /* HAVE_SIGNAL_H */ #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> static int keep_running;

        RETSIGTYPE
        stop_server(int a) {
            keep_running = 0;
        }

int
main (int argc, char **argv) {
/* print log errors to stderr */
snmp_enable_stderrlog();
/* we are a subagent */
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, "localhost:705");


        SOCK_STARTUP;  /* INSERTED BY  MAURIZIO RUBINI*/

          /* initialize the agent library */
          init_agent("mysubagent2");

          /* initialize your mib code here */
          init_test();

          /* ustMain will be used to read ustMain.conf files. */
          init_snmp("mysubagent2");

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

          /* main loop here... */
          while(keep_running) {
            agent_check_and_process(1);
          }

          /* at shutdown time */
          snmp_shutdown("mysubagent2");
          exit(0);
        }

and now it works.

Also the file example_demon.c ( in the tutorial ) needs a modify.

Any comments would be greatly appreciated.

Thanks & Regards.

Maurizio.




------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to