Compiling snmp++\agent++ without threads

Hello,

We have been using an older version of snmp++\agent++, and are planning to upgrade in the near future. The current versions are agent++ v3.5.31 and snmp++ v3.2.25. We have not upgraded yet as we would first like to figure out how to compile the new versions in single thread mode as well.

We have been able to compile the new snmp++ (v3.3.12) using the “–disable-threads” option, this does not appear to cause any issues. However, when we try to compile version v4.2.0 of agent++, we run into the following error:

ib.Tpo -c agentpp_config_mib.cpp -fPIC -DPIC -o .libs/agentpp_config_mib.o In file included from …/include/agent_pp/mib.h:35:0,
from …/include/agent_pp/agentpp_config_mib.h:28,
from agentpp_config_mib.cpp:39:
…/include/agent_pp/request.h:893:17: error: ‘Synchronized’ does not name a type
virtual Synchronized::TryLockResult trylock_request(Request*);
^
make[2]: *** [agentpp_config_mib.lo] Error 1

It looks like this is related to the “single threaded” snmp++ library. Is there a way to set agent++ to single threaded as well, or would we have to modify the source before compiling?

Regards

Hi,

AGENT++ does not work single threaded. Although AGENT++ in theory could work single threaded, it has not been developed for that since version 2.x and AgentX++ definitely needs multi-threading to work properly with at least 2 threads (4 or more is better).

Hope this helps anyway.

Best regards,
Frank

Hello,

If I understand correctly each SNMP request can be separately executed as a thread?(Also mentioned in the manual). In my project I have atleast 400 MIB Objects and the manager keeps polling the OIDs to read the current status, Does that mean there will be as many threads as requests or this can be configured/programmed otherwise?
In a current test scenario I have used only 9 MIB objects and when the agent run in controller I can see 7 threads started by the agent. Can I get description of the threads and the purpose of each threads some where in manual?

Thanks in advance.

Hi Nish1709,

Your question seems to refer to SNMP++ (i.e. sending SNMP requests and receiving their response). The conversation above was about AGENT++ (processing incoming requests and sending out responses).
In both cases there will be no 1:1 mapping between threads and requests. Rather than a thread pool with a configurable maximum size of threads is used. For SNMP++ you can use the asynchronous interface to avoid using threads at all (or to a minimum, if threads are enabled).

Best regards,
Frank

Hi All,
I am trying to upgrade to snmp++ 3.4.6 and agent++4.5.0.

I’d like to compile snmp++ with the option “–disable-threads” which I am able to successfully. However, agent++ fails compilation with the same error as posted above.
How do I proceed? Is this not a supported route any longer?

With older versions (snmp++3.3.5 and agent++4.0.4), I am able to perform the above compilations with option ‘–disable-threads’ with no issues.

Please advise. Thx.

As I wrote in a previous post in this thread, AGENT++ requires compilation with thread usage enabled since version 2.x (>20 years) now.
Why do you want to not use threads?

Thanks for the quick reply. After upgrading we are seeing intermittent crashes - see stack trace below. Engineers in the past have commented that they had issues running the threaded version. I am just trying to eliminate threading to help track down the issue.

Signal 11 caught. Backtrace:
1: ./libnwcore.so(BaseThread::TrapHandler(int)+0x137) [0xf7eb3447]
2: linux-gate.so.1(__kernel_rt_sigreturn+0) [0xf7fb0150]
3: /lib/libc.so.6(__libc_malloc+0x11c) [0xf5febdec]
4: /lib/libstdc++.so.6(operator new(unsigned int)+0x2b) [0xf62e056b]
5: /lib/libstdc++.so.6(operator new[](unsigned int)+0x1c) [0xf62e064c]
6: snmpagent(Oid::operator=(Oid const&)+0x67) [0x805d447]
7: ./libagent++.so.45(Vb::set_oid(Oid const&)+0x24) [0xf7c3d8dc]
8: ./libsnmp++.so.34(SnmpMessage::unload(Pdu&, OctetStr&, snmp_version&, OctetStr*, OctetStr*, long*, UdpAddress*, Snmp*)+0x81c) [0xf7ba9a98]
9: ./libagent++.so.45(SnmpMessage::unload(Pdu&, OctetStr&, snmp_version&)+0x31) [0xf7c758cf]
10: ./libsnmp++.so.34(receive_snmp_response(int, Snmp&, Pdu&, UdpAddress&, OctetStr&, bool)+0x2be) [0xf7bbc587]
11: ./libsnmp++.so.34(CSNMPMessageQueue::HandleEvents(int, fd_set const&, fd_set const&, fd_set const&)+0x1d1) [0xf7ba0405]
12: ./libsnmp++.so.34(CEventList::HandleEvents(int, fd_set const&, fd_set const&, fd_set const&)+0xa4) [0xf7b93540]
13: ./libsnmp++.so.34(EventListHolder::SNMPProcessPendingEvents()+0xf1) [0xf7b93c05]
14: ./libsnmp++.so.34(EventListHolder::SNMPProcessEvents(int)+0x1c3) [0xf7b93e0f]
15: ./libsnmp++.so.34(EventListHolder::SNMPBlockForResponse(unsigned long, Pdu&)+0x1f) [0xf7b93a69]
16: ./libsnmp++.so.34(Snmp::snmp_engine(Pdu&, long, long, SnmpTarget&, void ()(int, Snmp, Pdu&, SnmpTarget&, void*), void const*, int, int)+0xe6e) [0xf7bbf6aa]
17: ./libsnmp++.so.34(Snmp::get_next(Pdu&, SnmpTarget&)+0x42) [0xf7bbda64]
18: ./libagent++.so.45(SnmpRequest::process(int, UdpAddress const&, Vbx*, int&, Vbx*, int&, OctetStr const&, int, int)+0x272) [0xf7c76134]
19: ./libagent++.so.45(SnmpRequest::next(UdpAddress const&, Vbx*, int, int&, OctetStr const&)+0x7d) [0xf7c76cef]
20: ./libagent++.so.45(MibProxy::find_succ(Oidx const&, Request*)+0x262) [0xf7c9b972]
21: ./libagent++.so.45(Mib::find_next(MibContext*, Oidx const&, MibEntry*&, Request*, int, Oidx&)+0x1da) [0xf7c4ebf0]
22: ./libagent++.so.45(Mib::process_get_bulk_request(Request*)+0x99b) [0xf7c515db]
23: ./libagent++.so.45(Mib::do_process_request(Request*)+0x4c4) [0xf7c4ff94]
24: ./libagent++.so.45(MibTask::run()+0x74) [0xf7c841bc]
25: ./libagent++.so.45(TaskManager::run()+0x66) [0xf7c8308a]
26: ./libagent++.so.45(thread_starter(void*)+0x48) [0xf7c8251b]
27: /lib/libpthread.so.0(+0x6ec9) [0xf7ac3ec9]
28: /lib/libc.so.6(clone+0x6a) [0xf5f8411a]

I am thinking that the following line (903) in request.h needs to be wrapped in the macro “#ifdef _THREADS”

#ifdef _THREADS
virtual Synchronized::TryLockResult trylock_request(Request*);
#endif