Hello,

I'm embedding an agentx sub-agent in my application and now I would like to make my sub-agent became a master agent when a master agent is not present.

To make it clear: when my application starts it tries to connect to the master agent, if it could not connect to the master agent (for whatever reason, I dont care) it should start as a regular agent and serve requests for the MIB sub-tree it handles on a given UDP or TCP port.

I'm thinking about doing something like this:

---------------------------------------------------------------

// load only our MIB module and the modules it needs
setenv("MIBS", "", 1);
setenv("MIBFILES", "/path/to/my/mib/mymib.txt", 1);

netsnmp_ds_set_boolean( NETSNMP_DS_APPLICATION_ID,
        NETSNMP_DS_AGENT_ROLE, 1 );

if (init_agent("myapp") != 0) {
    netsnmp_ds_set_boolean( NETSNMP_DS_APPLICATION_ID,
            NETSNMP_DS_AGENT_ROLE, 0 );

    init_agent("myapp");
}

// initialize my mib code here
init_my_mib_module();

init_snmp("myapp");

if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
        NETSNMP_DS_AGENT_ROLE) == MASTER_AGENT) {

    init_master_agent();
    send_easy_trap(0, 0);
}
---------------------------------------------------------------

Then, in the file myapp.conf I would configure trap sinks and the UDP port my application should use to serve requests.

I took a look in the source code of the agent (snmpd.c and related files), but I'm not sure if this will work. Can any expert tell me if the code above will work?


Thanks, -- Ivens Porto OSE - Open Systems Engineering http://www.ose.com.br Phone: (55) 34 - 3214-5995 Fax: (55) 34 - 3214-5994 Cel: (55) 34 - 8816-9942


------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ Net-snmp-coders mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to