Counting with EEM

Unanswered Question
Oct 9th, 2007

Hi guys, as per my code below, every 20 seconds a syslog message is generated saying "Site is on ISDN" (I have set it to 20 seconds for testing purposes but will change it to 30 minutes before putting it into production). What I would like to do is instead of having the static message I would like it to say "This site has been on ISDN for X minutes". It would be as easy as doubling the variable every time the script is run but I'm not too sure how to use the count or increment options in the Applet. Any information/assistance would be greatly appreciated.

Thanks.

event manager applet isdn_on1

event syslog occurs 1 pattern "Line protocol on Interface Async1, changed state to up"

action 1.0 cli command "enable"

action 1.1 cli command "conf t"

action 1.2 cli command "event manager applet isdn_on2"

action 1.3 cli command "event timer countdown time 20"

action 1.4 cli command "exit"

event manager applet isdn_on2

event none

action 1.0 syslog priority 5 msg "Site is on ISDN"

action 1.1 cli command "enable"

action 1.2 cli command "conf t"

action 1.3 cli command "event manager applet isdn_on2"

action 1.4 cli command "event timer countdown time 20"

action 1.5 cli command "exit"

I have this problem too.
0 votes
  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 4.5 (2 ratings)
Loading.
Joe Clarke Tue, 10/09/2007 - 19:48

It sounds like what you want would be best achieved by converting your applet to a TCL policy. Currently, there is no way to do mathematical operations within an EEM applet policy.

Your timer policy could also be implemented as a watchdog which would reset the timer each time it runs.

voiper_99 Tue, 10/09/2007 - 20:12

I too thought TCL would be the best option but I have tried several times to follow all sorts of different tutorials to get this working but haven't had any luck. Are you able to help me out/give me any pointers? I'd really appreciate it.

Joe Clarke Tue, 10/09/2007 - 20:19

Please post what you have tried with TCL, and I will look it over.

voiper_99 Tue, 10/09/2007 - 20:25

Well that's the thing, I don't know where to start. I mean I have written a TCL script on a Cisco router before so everything on the router could be menu driven but with EEM I get confused with what to call and whether variables need to be environmental, etc. If I were to create a TCL script for this would you be able to tell me what is necessary to implement it?

However, I wouldn't know how to do things like searching the router's logs and adding log entries as I am no TCL expert.

voiper_99 Tue, 10/09/2007 - 20:33

By the way, what is the "counter" command for?

Router(config-applet)#action 1.0 counter name test op ?

dec Decrement the value of the counter by the given value

inc Increment the value of the counter by the given value

nop Read the value of the counter

set Set the value of the counter to the given value

Joe Clarke Tue, 10/09/2007 - 20:37

The counter action and event detector allow you to count something, then based on that counter value, execute another event. I thought about this, but I don't think it will do what you want. It sounds like what you want would best be handled with contexts using a TCL policy.

An example of chaining together a timer policy with a counter policy can be found in the EEM applet guide at http://www.cisco.com/en/US/products/ps6017/products_feature_guide_chapter09186a00804d7d47.html#wp1051302 .

Joe Clarke Thu, 10/11/2007 - 08:38

I have been very busy lately, but I will reply with a sample policy when I get a chance.

voiper_99 Thu, 10/11/2007 - 14:41

Great, I'd really appreciate that. Take your time though no need to rush.

Joe Clarke Wed, 10/24/2007 - 12:41

Here is an example TCL policy that should do what you want. To use it, copy it to your policy directory on flash, then register it:

event manager register isdn-timer.tcl type user

Then set an environment variable to tell the script which interface to watch to see if the router is running on ISDN. For example:

event manager environment isdn_interface Dialer0

Then you're done. It will run every 20 seconds, and do all of the checking for you. If it finds the router is on ISDN, it will send a syslog message. When it detects the router is no longer on ISDN, it will send a message then as well.

Attachment: 

Actions

This Discussion