SNMP Trap Error Disabled #2446
-
Is your feature request related to a problem? Please describe. I want to register events when a port goes in I successfully created an SNMP Trap handler for this. My initial idea is that this could be a sub-type of My Trap Handler works and generates the event, but for the life of me, I can't figure out how to get something else than "linkDown". I frankly can't even find how it becomes a "linkDown" sub-type. Describe the solution you'd like I would like to have an event raised for Describe alternatives you've considered Use a different system! Additional context I am more than willing to do the programming work - I am just a bit lost as to why my code is generating a Relevant code def post_link_event(netboxid, deviceid, interfaceid, modulename, ifname, ifalias, netboxname):
"""Posts a linkState event on the event qeueue"""
## https://nav.readthedocs.io/en/latest/reference/eventengine.html#attributes-explained
event = Event(
source="snmptrapd",
target="eventEngine",
netboxid=netboxid,
deviceid=deviceid,
subid=interfaceid,
eventtypeid="linkState",
state='s',
)
event['alerttype'] = 'linkErrDisabled'
event['module'] = modulename or ''
event['interface'] = ifname or ''
event['ifalias'] = ifalias or ''
try:
event.post()
except nav.errors.GeneralException:
_logger.exception("Unexpected exception while posting event")
return False
else:
return True
def verify_event_type():
"""
Safe way of verifying that the event- and alarmtypes exist in the
database. Should be run when module is imported.
"""
connection = getConnection('default')
cursor = connection.cursor()
sql = """
INSERT INTO alertType (
SELECT nextval('alerttype_alerttypeid_seq'), 'linkState', 'linkErrDisabled',
'Link error disabled'
WHERE NOT EXISTS (
SELECT * FROM alerttype WHERE alerttype = 'linkErrDisabled'));
"""
queries = sql.split(';')
for query in queries:
if query.rstrip():
cursor.execute(query)
connection.commit() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
To be clear, in my test, I am not generating SNMP traps for link up/down - that feature is turned off on that port. So the |
Beta Was this translation helpful? Give feedback.
-
Hi, @etlweather! Thank you for this report (which seems more like a question than a feature request/bug report), and my apologies for not responding sooner. This issue fell between the cracks of all the other issues our team is working on. You seem to be on the right track. Adding the However, You will need to change this plugin to achieve your goal: https://github.com/Uninett/nav/blob/master/python/nav/eventengine/plugins/linkstate.py This plugin contains the necessary logic for delayed alerts, assessing whether an alert should be generated at all (depending on NAV config) for the specific link. It also updates the link state fields of the Interface database model. If you have any questions about the plugin, dont' hesitate to ask, we will try to be more responsive going forward :) |
Beta Was this translation helpful? Give feedback.
Hi, @etlweather! Thank you for this report (which seems more like a question than a feature request/bug report), and my apologies for not responding sooner. This issue fell between the cracks of all the other issues our team is working on.
You seem to be on the right track. Adding the
alerttype
hint to an event usually works wonders for generic event handling; the event engine will create this alert type for the given event.However,
linkState
events in NAV have a special handler plugin in the event engine. This handler plugin only cares about the event type and state attributes, and uses these to decide which alerts to post. It completely ignores yourlinkErrDisabled
hint, as this alert …