I’ve got an AgentX module that watches for specific multicast traffic, pulls a
few bits out; and updates some counters accordingly. Consequentely I run the
AgentX in non-blocking mode; as to (also) be able attend to the socket in
parallel to handing SNMP requests.
Code below works splendidly:
my $agent = new NetSNMP::agent( 'AgentX' => 1, ...
$agent->register("my_agent_name", “webweaving::domotics3739”, ...
… set up some sockets & multicast subscription & put things in non-block.
while(1) {
..decode any multicast packets and update counters; all reads NONBLOCK
$agent->agent_check_and_process(1);
}
$agent->shutdown();
However it obviously spins fast in this while(1){} loop; which is all the more
a shame as both SNMP bulkwalks and multicast packets only come in every 100
seconds or slower.
What is the proper way to put a select() or poll() or similar onto the agent
(file descriptor) ? And are there any caveats ? Or is there some way to
register a handler on a fd separately ?
Much appreciated,
Dw.
------------------------------------------------------------------------------
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders