NetXMS Support Forum

English Support => General Support => Topic started by: gmonk63 on November 10, 2022, 08:15:08 PM

Title: SNMP Trap Threshold
Post by: gmonk63 on November 10, 2022, 08:15:08 PM
 Is there any way to set a threshold for received traps or alarms ? We have a few switches where the connected devices sometimes will have a faulty power supply and will randomly cause the device to constantly reboot causing the port to go up and down generating  SNMP_LINK_UP  SNMP_LINK_DOWN  traps.  I would like to generate an alarm/notification if there are say 10 or more back to back up down events received within 5min to notify me that the port is flapping. I think this would be useful to be able to do the same for certain alarms due to some alarms can trigger then rearm on the next check and can sometimes be easily missed.

Thanks.. 
Title: Re: SNMP Trap Threshold
Post by: Filipp Sudanov on November 11, 2022, 01:18:28 PM
This could be done using filtering script in EPP. That script should keep last 10 timestamps somewhere (in persistent storage or in custom attribute of the node, as comma-separated list) and check if all these timestamps fit within 5 min interval.
Do you need an example of such script?
Title: Re: SNMP Trap Threshold
Post by: gmonk63 on November 11, 2022, 11:05:21 PM
I will give it a try myself and if I can not figure it out I will circle back and ask for assistance.  Thank you for pointing me in the right direction.


Title: Re: SNMP Trap Threshold
Post by: gmonk63 on November 16, 2022, 03:12:08 AM
ok so I was able to to achieve what I wanted with the following its hacky  but if works. How do I go about terminating this alarm ? I want to terminate the alarm as soon as the time expires.


ts = ReadPersistentStorage("ts_".$node->name);

if(ts == NULL){
/* create initial timestamp and event*/
WritePersistentStorage("ts_".$node->name,$event->timestamp);
WritePersistentStorage($node->name,1);
return;
}
/* if within time range of 10min check storage */
if (time() - ts <=600){
 
events = ReadPersistentStorage($node->name);
WritePersistentStorage($node->name,events+1);
if (events!=NULL ){


if (events >=5){
return true;
}
}

}else{


/* if time is over 10min reset storage values for timestamp and event*/
WritePersistentStorage($node->name, NULL);
WritePersistentStorage("ts_".$node->name, NULL);



}