cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1932
Views
0
Helpful
2
Replies

How to use event parameters?

Aleksandr Serov
Level 1
Level 1

Hi

I've made simple eem applet for shutdown the port which trigered storm control event.

It is look like that:

event manager applet shut-storm

  event storm-control

  action 1.0 cli local python bootflash:shut-storm.py

and the script is

from cisco import CLI

from cisco import cli

import sys

import datetime

import time

import re

whitelist = [

"Ethernet1/1",

"Ethernet1/2"]

shlog = CLI('sh logg last 100 | i ETHPORT-5-STORM_CONTROL_ABOVE_THRESHOLD | last 3',False).get_output()

pat = re.compile(r'(\d{4} \w{3} \d{2} \d\d:\d\d:\d\d) \S+ \%ETHPORT-5-STORM_CONTROL_ABOVE_THRESHOLD: Traffic in port (Eth\S+|[Pp]o\S+)')

now = datetime.datetime.now()

delta = datetime.timedelta(seconds=180)

for l in shlog:

  mobj = pat.match(l)

  if mobj:

    port       = mobj.group(2)

    logTimeStr = mobj.group(1)

    logTimeObj = time.strptime(logTimeStr, "%Y %b %d %H:%M:%S")

    logTime    = datetime.datetime(*logTimeObj[:6])

    if now-logTime < delta:

      if port not in whitelist:

        cli("conf t")

        cli("interface %s" % port)

        cli("shutdown")

But the python script is a bit complecs because it shoud find triggered interfece in log.

Is it possible to use event parameters? And how?

I know that they are:

sw1# sh event manager history events det

Event ID Time of Event        Event Type                   Slot       Policies

32       09/30/2013 15:40:51  storm_control                active(1)  shut-storm

    interface = "Ethernet1/16", cause = "storm-control"

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

You should be able to do:

cli local python bootflash:shut-storm.py $interface $cause

However, calling Python scripts from EEM applets on Nexus is not officially supported yet, so your mileage may vary.

View solution in original post

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

You should be able to do:

cli local python bootflash:shut-storm.py $interface $cause

However, calling Python scripts from EEM applets on Nexus is not officially supported yet, so your mileage may vary.

Thank you Joseph.

It works.

Now the applet looks like:

event manager applet shut-storm2

  event storm-control

  action 1.0 cli local python bootflash:shut-storm2.py $interface

And the script:

from cisco import cli

from syslog import syslog

import sys

whitelist = [

"Ethernet1/1",

"Ethernet1/2"]

port = sys.argv[1]

if port not in whitelist:

  cli("conf t")

  cli("interface %s" % port)

  cli("shutdown")

  syslog(2, "Interface %s was shutdown due to storm conditions" % port)

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: