no cold start up traps

I am using AGENT+±4.3.1/SNMP+±3.4.2 and build examples. I tried “atm_mib” and “multi_agent” examples, but don’t see the coldStart being send from either. I made sure the IP address of the trap destination is correct. Also, I have enabled log/debug with max value and don’t see any log about sending the trap. I monitored network with wireshark and also packet monitor in mib-explorer, but did not see any.
The walk and get from mib-explorer works fine. No issue here.

Please, help if I did miss something in the configuration or what it is that I missing to got traps/notification works?

Regards,
Safet

Hi Safet,

When I am starting the unmodified atm_mib sample agent, I see the following log line:

20201218.03:45:32: 4585348608: (1)EVENT  : NotificationGenerator: sent v1 trap (id)(tdomain)(addr)(vbs)(community): (1.3.6.1.6.3.1.1.5.1), (1), (127.0.0.1/162), (0), (public)

Maybe you changed something to break it?

Best regards,
Frank

I did not change the code at all, but IP address Here it is:

Vbx* vbs = 0;
coldStartOid coldOid;
NotificationOriginator no;
// add an example destination
UdpAddress dest("10.5.5.29/162");
no.add_v1_trap_destination(dest, "defaultV1Trap", "v1trap", "public");
// send the notification
mib->notify("", coldOid, vbs, 0);

I used both visual studio project and linux target. I did some debugging and see that during process of add_v1_trap destination “targetParmasEntry” and “targetAddrEntry” are still NULL.
Due to this there is no entry in the targetAddress table and notify will not send it.

Regards,
Safet

Hi Safet,

Maybe you created somehow a persistent configuration file were the necessary configuration rows are missing. Then you should delete reset that configuration.

Another problem could be that due to some autoconf setting, necessary implementation modules (SNMPv3 MIBs) are not available and therefore the configuration fails. But that should be noted with WARN or ERROR log entries in the log.

Best regards,
Frank

Hello Frank,

I did not modify the code at all.

What I did I used the next line:
no.add_v2_trap_destination(…) and I got the trap now. Why v1 doesn’t work?

Also I need help how to use the notify function for NOTIFICATION-TYPE. I see that for each NOTIFICATION-TYPE object in my MIB the agenpro generate a class that have only “notify” function declared and implemented. When this function will be called?
How I can call this function somewhere from code where I monitor for changes in leafs?
Also, what is recommended practice to scan if a leaf change value and generate a trap/info?

Regards,
Safet

@jkatz, just informed me that there is a bug in the v1 trap destination sample code. But because this is sample code anyway, it does not affect your own trap destination configuration implementation. The sample codes were never meant for production because you will need to handle more details than available by those interfaces.

Nevertheless, I will fix (rework) the sample code to work even for v1.

Hello Frank,

I understand the this is the sample code. But issue is that this is the only stuff to figure out how the AGENT++ works. There is no guide how to implement traps/notification/inform. Like you have the document for older version of AGNET++ that shows how and when get_request is used. This document should be updated and give examples how to used notify and traps etc.
As I mention in previous post I have no clue when the function “notify” and under what condition will be called, if called at all. Should be a custom scanning thread introduced or not?
This details are very important to use the library in the full capacity. Now everything is base on samples and digging throughout the code to figure out how do achieve something.
At least I found this being issues for me.

I would really appreciate if you would help about the notification/traps.

Regards,
Safet

Hello Frank,

Can I get any help in regards when the notify will be called from AGENT++/SNMP++ frame work for a NOTIFICATION-TYPE object?

Regards,
Safet

Hello Safet,

That is easily answered: the AGENT++ framework will never call notify for custom NOTIFICATION-TYPEs.
Your instrumentation code is responsible to call notify in order to send a notification to the configured targets.

Best regards,
Frank

Hello Frank,

Thank you. I was hopping that there is some built-in scanning procedure to check if any NOTIFICATION-TYPE change to generate traps.

Regards,
Safet

Hello Frank,

What would be the fastest way to traverse the whole list of MibLeaf added to Mib from agent code (agent.cpp) where I have only pointer to Mib?

Regards,
Safet

  1. Get the context first with mib->get_context(const NS_SNMP OctetStr&);

  2. Then iterate through the objects:

     MibContext* context = mib->get_default_context();
     context->start_synch();
     OidListCursor<MibEntry> c(context->get_content());
     for (; c.get(); c.next()) {
     	if (c.get()->type() == AGENTPP_LEAF) {
     		// synchronized
     		((MibLeaf*)c.get())->do_something();
     	}
     }
     context->end_synch();

Thank you. Very helpful.

Hello Frank,

Where I can find the fix for the v1 trap in the sample code?

I also noticed that if want to send v3 trip the application simple exit as soon as it make the call
to “add_v3_trap_destination”. I am sure I provided the right parameters to “add_v3_trap_destination”. Can you please, check this one too?

This far I see only trap v2 works without any issues.

Regards,
Safet

Hello,

you can just download the latest AGENT++ 4.5.0 and either use the new version with the fix or patch your version with the changed NotificationOriginator::add_v1_trap_destination() function.

I’m currently checking the v3-issue…

Kind regards,
Jochen

Hello,

you have to patch the add_v3_trap_destination() function. Change the line

if (!get_snmp_target_addr_entry() || !get_snmp_target_params_entry())

to

if (!get_snmp_target_addr_entry() || !get_snmp_target_params_entry() || !get_snmp_notify_entry())

Kind regards,
Jochen

Hello Jochen,

I tested and can see now that v1 and v2 work fine. With v3 I need to check why I am getting no access reason when a trap is to be send out.

Thank you for your help.

Regards,
Safet

Hello,

I wanted from the same device to send to different Trap receivers different trap versions, but it doesn’t work. All the depends on the first call if it is add_v1_trap first then, even if for the some other receiver the call is: add_v2_trap, but it still sends v1 trap and even use the same IP address???
Is this not allowed in SNMP or I am doing something wrong?

Please, help.

Regards,
Safet

As often written here and elsewhere in the past years:

The add_vX_trap... methods are oversimplified examples only. Never try to use this for something in production!

Saying that, of course you can send different traps to different targets! You “simply” need to configure it right. You will need different target parameter sets and target definitions and use different notification tags.

Hello Frank,

I am sure that my configuration is correct, I can attach a LOG if needed.
I have three use cases:
In use case 1 configuring the same IP, but trying to send two different trap versions (v1 and v2).
In use case 2 configuring two different IP addresses, and the same trap version (v1 and v1 or v2 and v2).
In use case 2 configuring two different IP addresses, and different trap versions (v1 and v2)
LOG shows correct configuration, but on the wire (with wireshark) I see always the same package send twice while the second never show up.

What method then I have to use to add a trap?

Regards,
Safet