Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

Counting with EEM

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"

9 REPLIES
Cisco Employee

Re: Counting with EEM

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.

New Member

Re: Counting with EEM

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.

Cisco Employee

Re: Counting with EEM

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

New Member

Re: Counting with EEM

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.

New Member

Re: Counting with EEM

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

Cisco Employee

Re: Counting with EEM

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 .

Cisco Employee

Re: Counting with EEM

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

New Member

Re: Counting with EEM

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

Cisco Employee

Re: Counting with EEM

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.

178
Views
9
Helpful
9
Replies