...
Note |
---|
If any of these three event properties are not set state will not function well. Consider a case where the element property is not set; thus being null. In this case if a 'port down' for gig0/0 was received a 'port up' for gig0/1 would clear the g0/0 'port down' event. Without the element being set opEvents cannot differentiate between interfaces. |
Example parser rule for the element property.
Code Block |
---|
53 =>"53" : { IF => qr/"IF" : "IF-MIB::ifIndex\\.\\d+=(\\d+)/", "THEN" : [ THEN => ["capture(element)"], ] }, |
Example parser rule for the stateful property
Code Block |
---|
51 =>"51" : { IF => qr/"IF" : "IF-MIB::linkDown/", "THEN" : [ THEN => ["set.event(Interface Down)", "set.stateful(Interface)", "set.stateful(Interface)", "set.state(down)", "set.state(down)", "set.priority(3)" ], ] }, |
...
Create Parser Rules
opEvents will process the trap log file as specified on opCommon.nmis. When parsing the traps, at least the following properties should be extracted:
...
Based on this we can write the regular expression to set the element.
Code Block |
---|
"2 =>": { "DESCRIPTION => '": "Set element for card number.'", "IF => qr/": "(STARENT-MIB::starSlotNum=\d+)/", "THEN": => ["capture(element)"], }, |
Notice the regular expression will catch an number of digits following the '=' character. This rule 'captures' the element. In this way we can dynamically assign event properties based on a regular expression.
...
Info |
---|
Notice that if the author is creative and accurate with regular expressions the number of rules my be decreased. |
Code Block |
---|
"103 =>": { "IF => qr/": "STARENT-MIB::starCardTempOK/", "THEN => [": [ "set.event(Card Temperature OK)", "set.stateful(temperature)", "set.state(up)", "set.priority(2)" ], }, |
Based on a match of "STARENT-MIB::starCardTempOK", the rule will take action.
- event - "Card Temperature OK"
- stateful - "temperature"
- state - "up"
- priority - "2"
...