How to use event parameters?

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"

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)

Similar Messages

  • Why and how to use events in abap objects

    Dear all,
      Please explain me why and how to use events in abap objects with real time example
    regards
    pankaj giri

    Hi Pankaj,
    I will try to explain why to use events... How to use is a different topic.. which others have already answered...
    This is same from your prev. post...
    Events :
    Technically speaking :
    " Events are notifications an object receives from, or transmits to, other objects or applications. Events allow objects to perform actions whenever a specific occurrence takes place. Microsoft Windows is an event-driven operating system, events can come from other objects, applications, or user input such as mouse clicks or key presses. "
    Lets say you have an ALV - An editable one ...
    Lats say - Once you press some button  you want some kind of validation to be done.
    How to do this ?
    Raise an Event - Which is handled by a method and write the validation code.
    Now you might argue, that I can do it in this way : Capture the function code - and call the validate method.
    Yes, in this case it can be done.. But lets say .. you change a field in the ALV and you want the validation to be done as soon as he is done with typing.
    Where is the function code here ? No function code... But there is an event here - The data changed event.
    So you can raise a data changed event that can be handled and will do the validation.
    It is not user friendly that you ask the user to press a button (to get the function code) for validation each time he enters a data.
    The events can be raised by a system, or by a program also. So in this case the data changed event is raised by a system that you can handle.
    Also, Lets say on a particular action you want some code to trigger. (You can take the same example of validation code). In this case the code to trigger is in a separate class. The object of which is not available here at this moment. (This case happens very frequently).
    Advantage with events : Event handlers can be in a separate class also.
    e.g : In the middle of some business logic .. you encounter a error. You want to send this information to the UI (to user - in form of a pop up) and then continue with some processing.
    In many cases - A direct method call to trigger the pop up is not done. Because (in ideal cases) the engine must not interact with UI directly - Because the UI could be some other application - like a windows UI but the error comes from some SAP program.
    So - A event is raised from the engine that is handled in the UI and a pop up is triggered.
    Here -- I would have different classes (lets say for different Operating Systems). And all these classes must register to the event ERROR raised in application.
    And these different classes for different Operation systems will have different code to raise a pop-up.
    Now you can imagine : If you coded a pop-up for Windows (in your application logic) .. it will not work for Mac or Linux. But of you raise a event.. that is handled separately by a different UI classes for Win, Linux or Mac  they will catch this event and process accordingly.
    May be I complicated this explanation .... but I couldn't think of a simpler and concrete example.
    Cheers.
    Varun.

  • How to use event structure of event data nodes event filter nodes in programming

    hi,
    I need manual of how to use 'event structure' events of 'event data nodes' and 'event data filters'...please help me....
    Regards
    Ravindranath

    I'm not really sure what you are looking for here.  Did you do a search in the LabVIEW help for Event Structure?
    The Event Data Node just returns information about the event, like control data, control reference, what caused the event, etc.
    The Event Data Filters are just used in Filter Events.  This allows you to discard an event or change the data that the event will recieve.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • DAQmx 7.5 - how to use Events in VB 6.0

    I'm using the type library (nidaqmx.tlb) supplied by DAQmx 7.5 to control a NI PCI-6251 board from VB 6.0
    (unfortunately Measurement Studio does not support this board for VB 6.0 anymore).
    Is there any tutorial or example describing how to use events (e.g. DAQmxRegisterEveryNSamplesEvent)
    in VB 6.0?

    hi, you must create connection like this:
    Set Connection = New ADODB.Connection
    Connection.Open "Provider=OraOLEDB.Oracle; " & _
    "Data Source=" & strServer & "; " & _
    "User ID=" & strUserName & "; " & _
    "Password=" & strPassword & "; "
    where strUserName - your user,
    strPassword - password to your user,
    strServer - alias to your server.
    My Oracle 10g is installed on c:\oraclexe\...in access you have database file, in oracle - data source
    your alias is maybe XE, if not you seek it in file tnsnames.ora which is in path like this c:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN
    Andy

  • How to Enter Event Parameters in FM SAP_WAPI_CREATE_EVENT_EXTENDED

    Hi,
    I am trying to trigger theEvent 'START_RM_WEBREQ' for an ABAP Class 'CL_HREIC_RM_WORKFLOW' using the above mentioned FM.
    Usually this can be done using SWUE, however I am asked to do it create a custom program that would do the functionality for SWUE.
    Problem is I cannot figure out how do I enter the Parameters of the Event via this FM SAP_WAPI_CREATE_EVENT_EXTENDED.
    The event parameters for the event 'START_RM_WEBREQ' is Object Type and Key. Usually when doing it via SWUE we are prompted with a dynamic screen which asks us to populate the values.
    Please help.
    Thanks,
    Pablo

    Hi,
    Thank you for your response. But I am facing the same problem there. I am not able to populate the value of the Parameter for the event START_RM_WEBREQ.
    The code I had written initially is similar to the one in the link that you have sent:
    TABLES: swotobjid.
    SELECT-OPTIONS: s_notif FOR swotobjid-objkey NO INTERVALS .
    DATA: lv_objtype TYPE sibftypeid,
          lv_event   TYPE sibfevent,
          lv_objkey  TYPE sibfinstid,
          lr_event_parameters TYPE REF TO if_swf_ifs_parameter_container,
          lv_param_name TYPE swfdname,
          lv_value   TYPE char80.
    lv_objtype = 'CL_HREIC_RM_WORKFLOW'.
    lv_event   = 'START_RM_WEBREQ'.
    LOOP AT s_notif.
      lv_objkey  = s_notif-low.
    *Instantiate an empty event container
      CALL METHOD cl_swf_evt_event=>get_event_container
        EXPORTING
          im_objcateg  = cl_swf_evt_event=>mc_objcateg_cl
          im_objtype   = lv_objtype
          im_event     = lv_event
        RECEIVING
          re_reference = lr_event_parameters.
    *Set up the name/value pair to be added to the container
      lv_param_name = 'NOTIFICATION'.
      CONCATENATE 'BUS7051' lv_objkey INTO lv_value SEPARATED BY space.
    *Add the name/value pair to the event conainer
      TRY.
          CALL METHOD lr_event_parameters->set
            EXPORTING
              name  = lv_param_name
              value = lv_value.
        CATCH cx_swf_cnt_cont_access_denied .
        CATCH cx_swf_cnt_elem_access_denied .
        CATCH cx_swf_cnt_elem_not_found .
        CATCH cx_swf_cnt_elem_type_conflict .
        CATCH cx_swf_cnt_unit_type_conflict .
        CATCH cx_swf_cnt_elem_def_invalid .
        CATCH cx_swf_cnt_container .
      ENDTRY.
    Raise the event passing the prepared event container
      TRY.
          CALL METHOD cl_swf_evt_event=>raise
            EXPORTING
              im_objcateg        = cl_swf_evt_event=>mc_objcateg_cl
              im_objtype         = lv_objtype
              im_event           = lv_event
              im_objkey          = lv_objkey
              im_event_container = lr_event_parameters.
        CATCH cx_swf_evt_invalid_objtype .
        CATCH cx_swf_evt_invalid_event .
      ENDTRY.
      COMMIT WORK.
      MESSAGE s736(wz).
    ENDLOOP.

  • How to use Event Tracking Code for Google Analytics in Dreamweaver CS5

    I need to track clicks on links that go to an outside website. I've read about "event tracking code". I'm not sure if it's the right tool to use. And if it is, I've spent several hours reading about it and I can't figure out how to use it. It looks like you need to be an expert developer to be able to make sense of all this. I've always been helped when I ask a question here, I'm hoping that someone can help me.
    What my client needs is to know what links are being clicked, and how often. Here's the page where I want to do this: Available Homes - Arizona Vacation Home Rentals 
    I added a code that I created using the tool I found here: General Event Tracking Code for Google Analytics but can't see to be able to make this work. I added this code to the first link called "View it Here" for the top, left house. Here's the code: <a href="http://www.homeaway.com/vacation-rental/p3495538" onClick="ga('send', 'event', { eventCategory: 'clicks', eventAction: 'clicks on homes', eventLabel: 'Clicked'});" target="_blank">View it HERE!</a> 
    Then I set a Goal in Google Analytics like it said in the instructions but it doesn't seem to work... I would APPRECIATE ANY HELP!
    Thanks,
    Brigitte

    I think you misunderstood what Event Tracking is designed for.  This is from Google Help
    Tracking Code: Event Tracking - Google Analytics — Google Developers
    "Use this to track visitor behavior on your website that is NOT related to a web page visit, such as interaction with a Flash video movie control or any user event that does not trigger a page request."
    Clicks on links are page requests.  I think for your purposes, you may want the Cross Domain Link Tracking plugin.
    Cross Domain Tracking - Web Tracking (analytics.js) - Google Analytics — Google Developers
    Nancy O.

  • How to use Default parameters

    Hello,
    How do I use default parameters from ODP.NET. I have a proc in Oracle that shows Default? = Y when I do Describe in PL/SQL Developer. Therefore, I don't want to pass this parameter at all via ODP.NET/C# call. If I omit this parameter, I get the dreaded "Invalid number or types of parameters" error.
    Thanks for your help,
    Evgueni

    Hi,
    You'll just want to set OracleCommand::BindByName=true. Here's an example, hope it helps.
    Greg
    create or replace function showparams(p1 varchar2, p2 varchar2 default 'foo',
               p3 varchar2, p4 varchar2 default 'bar') return varchar2
    is
    retval varchar2(4000);
    begin
    retval := 'p1 = '|| p1;
    retval := retval || ',p2 = ' || p2;
    retval := retval || ',p3 = ' || p3;
    retval := retval || ',p4 = ' || p4;
    return retval;
    end;
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    class testdefault
        static void Main(string[] args)
            using (OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger"))
                con.Open();
                using (OracleCommand cmd = new OracleCommand("showparams", con))
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.BindByName = true;
                    cmd.Parameters.Add( new OracleParameter("retval", OracleDbType.Varchar2,4000));
                    cmd.Parameters["retval"].Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add("p1", "firstval");
                    cmd.Parameters.Add("p3", "secondval");
                    cmd.ExecuteNonQuery();
                    Console.WriteLine(cmd.Parameters["retval"].Value.ToString());
    }OUTPUT
    =========
    p1 = firstval,p2 = foo,p3 = secondval,p4 = bar
    Press any key to continue . . .

  • How to use HTML parameters in Java applet

    Hello
    In perl I have created a form with things like a selectiuon box called currency and text fields called product for example. Then when I click submit the perl program can pick up the currency and product parameters.
    I have read about applet param eg <param name="param1" value="Apple"> is this the same thing? Or is it different?
    Can I use HTML parameters or do I need to use applet param? I am confused.
    If applet param is what I need, then how do I change the param values say by editing text in a text field?

    You will need to use Java Native Interface JNI. Ther are many posts on the subject, please search, and this is the documentation:
    http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/jniTOC.html

  • How to use Import parameters of a search help

    Hi,
    Could you please tell me how to use import & export parameters of a search help in the report.

    Hi,
    Import parameters are imported from the selection screen of the report into the search help and then these are used to query in the search help.
    For example
    case 1.
    parameters : p_carrid like sflight-carrid.
    parameters : p_connid like sflight-connid.
    the search help that is used in the above condition is
    SFLIGHT.
    And the selection method is SFLIGHT in this search help.
    ( to check which search help is used go to se11 display the table and put your cursor on the field and in the menu for goto--> search help.)
    so when you do an F4 on connid it looks for a field which is declared like SFLIGHT-CARRID ( and the value entered in it) since the SFLIGHT-CARRRID is an import parameter in the search help,  and queries the database where the value is equal to the p_carrid which is declared like SFLIGHT-CARRID and gets only data which is equal to carrid
    case 2.
    parameters : p_carrid like SCARR-carrid.
    parameters : p_connid like sflight-connid.
    In this case the system will fetch all the data.
    since there is no parameter for SFLIGHT-CARRID on the selection screen it would get all the data from SFLIGHT.

  • How to use event to detect the change of a array variable?

    I have a main application that includes a lot of sub
    components. the main app mxml file import a public class that
    includes an array variable. Each of the values in the array can be
    updated in the sub components.
    I would like to have the main mxml be able to detect the
    change of the values of the array. Is it possible to use event? And
    how? Is there a good example to follow?

    See this FB3 help topic, particularly watchers:
    Defining data bindings in ActionScript

  • How to use init parameters?

    Is it posible to use init parameters with FacesServlet?
    With any other servlet I'd do this:
    <servlet>
    - <init-param>
      <param-name>base</param-name>
      <param-value>/shop</param-value>
      </init-param>
    </servlet>but it doesn't seem correct to the same with the FacesServlet ie:
    <servlet>
      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    - <init-param>
      <param-name>imageURL</param-name>
      <param-value>/images/</param-value>
      </init-param>What is the right way to use init params with JSF?

    You don't have control over the FacesServlet.
    Rather use the context-param.
    <context-param>
        <param-name>paramName</param-name>
        <param-value>paramValue</param-value>
    </context-param>
    String paramName = facesContext.getExternalContext().getInitParameter("paramName");

  • How to use URL parameters in Flex?

    Hello Everyone,
    I wanted to know how can the parameters passed in a URL be used in our Flex application. I searched in the forum and tried these links:
    http://forums.adobe.com/message/217950#217950
    http://www.danvega.org/blog/index.cfm/2009/2/5/Flex-FlashVars-in-local-development
    In the second link, this is the solution provided:
       1. // if we've detected an acceptable version
       2. // embed the Flash Content SWF when all tests are passed
       3. AC_FL_RunContent(
       4.         "src", "ffManager",
       5.         "width", "100%",
       6.         "height", "100%",
       7.         "align", "middle",
       8.         "id", "ffManager",
       9.         "quality", "high",
      10.         "bgcolor", "#869ca7",
      11.         "name", "FFManager",
      12.         "allowScriptAccess","sameDomain",
      13.         "type", "application/x-shockwave-flash",
      14.         "pluginspage", "http://www.adobe.com/go/getflashplayer",
      15.         "flashvars","username=dvega"
      16. );
    private function init():void {
        // grab the username so we can track who is logged in
        [Bindable] private var:username= Application.application.parameters.username;
    But here, I am getting the hardcoded value (ie.,dvega) as the data inside my flex application. Instead I would need the dynamic data that is passed through the URL. For Ex: if I use the URL, http://172.22.41.154/MH_2.html?myName=Arush
    I need would need to use the name 'Arush' inside the application. Can you please help me on how and what part of the code is to be modified?
    Thank you,
    Warm regards,
    Deepak

    That would come within flex.
    In my case, there is a SAP CRM web application which has a push button. On click of this button, flex URL is called(ie., http://172.22.41.154/MH_Bluebook_Integration2.html). On click of that button I need to pass an Object ID, which is passed withing that flex URL, something like this:
    http://172.22.41.154/MH_Bluebook_Integration2.html?objID=abcd
    I need to receive 'abcd' in the flex. Any way we could modify the HTML wrapper to send this value to swf? 

  • How to use additional parameters in SM49

    Hi,
    I wrote a CMD file witch copies a file from one directory to another, the source and destention are both parameteres,
    how do I sent the 2 parameters using SM49?
    the command file looks like this:
    copy %1% %2%
    The system is windows
    Thanks,
    Naama.

    Right click on the References node in the project navigator and select: Add New Library Reference. In the subsequent dialog, specify the path to the jar file you wish to include. This library will be automatically added to the application classpath at design time and deployed with the application when you run the project.

  • How to use Style Parameters ?

    Hi,
    in JDEV I have created a VO with a query (pasted from sqlplus) that does a select cross a couple of tables. I need to parameterise the query but cant see how to do it. It looks like you could use
    ' where table.atttribute = :1' as part of the query in the View Object designer. Selecting the check box ? Style Parameters means the sql tests as valid. But when you apply the changes you get a value not bound error.
    How do you get the parameter from (for example) a form value, into the view ? Is there a way to do this and ignore the variable not bound error mentioned above ?
    Seems like it should be intuitive, but I've obviously missed that bit of the developers guide :-)
    Any pointers would be great.
    Paul

    There is no direct way to bind the Form Fields to the query.
    You need to do the following:
    Use the pageContext.getParameter("param_name") to get the value for the form field.
    Use the am.invokeMethod to bind the variable as below in your view method:
    setWhereClauseParams(null); // Always reset
    setWhereClause(null);
    setWhereClauseParam(0,qotHdrId);
    executeQuery();
    This should work. Hope this helps.

  • How to use DATETIME parameters in stored procedure?

    I can not define a variable or parameters
    with data type of DATETIME
    when I define stored procedure using Developer/2000.
    Does Oracle not support DATETIME?
    null

    Chen Honghua (guest) wrote:
    : I can not define a variable or parameters
    : with data type of DATETIME
    : when I define stored procedure using Developer/2000.
    : Does Oracle not support DATETIME?
    Oracle supports DATETIME data type.
    "DATETIME" data type is stored in "DATE" data type.
    if you want to DEFINE "10-Jan-1998 10:20" :
    declare
    dummy_date date:=to_date('10-jan-1998 10:00','DD-MON-YYYY
    HH24:MI');
    BEGIN
    END;
    null

Maybe you are looking for

  • Icloud storage upgrade - unknown error occured

    Hi, I have a problem while upgrade my iCloud storage. After buying 10 GB and apply with password a error occure: "a unknown error occurs" -> german error message "Ein unbekannter Fehler ist aufgetreten". So I cannot finish process and hold on 5 GB st

  • How to retreive String from the Connection object

    hi all, I am using HttpConnection to Connect to the server.I want to retreive string from the Connection. As like Connection.openInputStream() is there any method to get the String from the connection.In the server side also i want to send the String

  • Forms with Native(ZCI) Layout.

    Hi Experts, I am developing Forms with Native(ZCI) Layout. Offline the form is working fine. But online the form is creating issues. I have a button on my web dynpro screen. When I click on it to save the data in the form the form gets reloaded and d

  • Initialize values in 1001

    I want to initialize values in IT1001 thrue a measure. Is it possible with a  BADI or a User_Exit?If yes, which one?

  • Unable to use HDMI IN port on B550

    Hi, I am unable to use the HDMI IN port on the B550, whenever i switch to HDMI mode, the screen is blank with no signal. But HDMI OUT port seems to work. anybody with similiar problems to this?