This document describe about configuring EEM Script for periodically clearing interface counters using regular expression.
Before moving to configuration I would like to describe some basic things use in the script:
1) Watchdog System detector: watchdog detector generates periodic timer events that allow EEM script to run at repeating time intervals.
2) "event tag event-tag timer watchdog time”: To specify the event criteria for an EEM applet that is run on the basis of time-specific events, use the event timer command in applet configuration mode.
3) "action info type interface-names" :Specifies the action of obtaining interface names when an EEM applet is triggered.
4) Specifying foreach Iterating Statements:
To specify a conditional statement that iterates over an input string using the delimiter as a tokenizing pattern, perform this task. The foreach iteration statement is used to iterate through a collection to get the desired information. The delimiter is a regular expression pattern string. The token found in each iteration is assigned to the given iterator variable. All arithmetic calculations are performed as long integers without any checks for overflow. In this task, the value of the variable x is set to 5. An iteration statement is set to run through the input string red, blue, green, orange. For every element in the input string, a corresponding message is displayed on the screen.use below command syntax to specify foreach statment under event manager.
"action label foreach [string-iterator] [string-input] [string-delimiter]"
5) Regular Expressions: Using regular expressions, you can specify the rules for a set of possible strings to be matched.
Command sytax:" action label regexp string-pattern string-input [string-match [string-submatch1] [string-submatch2] [string-submatch3]]"
On Router R1 ,I have serial as well as fastethernet ports but we are configuring script using regular expression in such way that it will only periodically clear fastethernet interfaces counter but serial interface counter remain unchanged.
no ip address
ip address 10.1.1.1 255.255.255.0
no ip address
ip address 188.8.131.52 255.255.255.0
serial restart-delay 0
Interface status before configuring EEM script:
Configuring EEM script on R1:
To verify applied script we are debugging as shown below:
From the above output; script is only clearing fastethernet interface counter not for serial interfaces.