Script to run Python with EEM on Nexus 9K

Hello!

I am trying to run the example provided in the following link for "Running Scripts with Embedded Event Manager":

http://www.Cisco.com/c/en/us/TD/docs/switches/Datacenter/nexus9000/SW/6-...

Here is my configuration of the Nexus 9 K switch EEM:

NX9K-autonomous-Pod-1 # sh run EEM

! Command: show running-config EEM
! Time: Sat Nov 15 09:54:52 2014

version 6.1 (2) I3 (1)
Event Manager applet a1
cli event corresponds to "display the clock.
Action 1 cli python bootflash:pydate.py
2 default event action
Action 3 syslog msg I like EEM

And here is an example of work of pydate.py that I grabbed from GitHub:

GitHub Repo: https://github.com/haya14busa/pydate/blob/master/pydate.py

NX9K-autonomous-Pod-1 # python bootflash:pydate.py
DATETIME = 2014-11-15 09:47:03
TIMESTAMP = 1416044823
DateTime: 2014-11-15 09:47:03-> TimeStamp: 1416044823
TimeStamp: 1416044823-> DateTime: 2014-11-15 09:47:03
NX9K-autonomous-Pod-1 #.

Finally, here is what happens when I run the command 'See the clock' in an attempt to trigger the EEM applet:

NX9K-autonomous-Pod-1 # sh clock
09:54:58.746 UTC Saturday, November 15, 2014
NX9K-autonomous-Pod-1 # 2014 Nov 15 09:54:58 NX9K-autonomous-Pod-1% VSHD-5-VSHD_SYSLOG_CONFIG_I: configured for the vty by admin on vsh.8883
2014-15 Nov 09:54:58 NX9K-autonomous-Pod-1% VSHD-5-VSHD_SYSLOG_CONFIG_I: configured for the vty by admin on vsh.8894

Any help is appreciated!

The syslog message must come before the 'event' by default.  As for what the Python script prints, it won't happen when she is called to the EEM.  But you may like the Cisco.com article says, look at the log to make sure that the script ran.

Tags: Cisco Network

Similar Questions

  • Download a file using a php script when running applications with LCD screens

    Hello! I'm developing an application in Flex 2 / Java - running on the LCD / JRun server.

    I'm trying to add downloading features. I use a script php to the download section.

    First, I'm just trying to put the script in the application directory. Does not work.
    After that I created an apache server where I put a small web site with my script. He tells me that my file is downloaded correctly, but I can't find the file. The apache log I don't give no errors.

    Can someone help me?

    Originally, I had problems w / the file placed in C:/whatever.ext b/c I was not using relative paths.

    This is the code I use:
    --------------------------------

    $MAXIMUM_FILESIZE = 1024 * 1024 * 2; 2 MB
    $newFileLoc = '. '. "/ wherever/file.jpg.

    If ($_FILES ['Filedata'] ['size'])<= $maximum_filesize)="">

    move_uploaded_file ($_FILES ['Filedata'] ['tmp_name'], ".") / temporary / ". $_FILES ['Filedata'] ['name']);"

    Rename ("./temporary/". $_FILES ['Filedata'] ['name'], $newFileLoc);
    chmod ($newFileLoc, 0777);

    }

    ---------------------------

    Editing of this article by Adobe:

    http://livedocs.Adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=live Docs_Book_Parts & file = 17_Networking_and_communications_173_6.html

  • Making existing EEM applets simple scripts Tcl or python.

    Hi all

    I would like to make the existing simple EEM of scripts Tcl or python applets.

    For monitoring the nodes in ITD service, I set up an EEM applet with a knot.

    But the nodes keep adding EEM applets are also added as many nodes.

    That's why EEM configuration get more complex so I should find a solution.

    I think it might be Tcl or Python scripts.

    Could check you if it of possible or not?

    -Monitor the model track or syslog on the nodes of the ITD downwards or upwards.

    -When the ITD nodes get downwards or upwards, the associated script the event trigger to add or delete a device group.

    Order to reduce EEM applets I want variable allows you to exactly identify node under status change of situation.

    Here are the current configurations of EEM.

    Event Manager applet remove_inside_node1
    event track State 101
    order cli action 1 'enable '.
    Action 2 cli command "conf t".
    Action 3, command cli "itd session device-group ips_inside.
    Action4 'no node ip 1.1.121.1' cli command
    Action 5 cli command "commit".
    action 6 cli command 'end '.
    Action 7 "INFO: removed the 1.1.121.1 node.

    Event Manager applet add_inside_node1
    101 State event track upward
    order cli action 1 'enable '.
    Action 2 cli command "conf t".
    Action 3, command cli "itd session device-group ips_inside.
    Action 4 cli command "node ip 1.1.121.1.
    Action 5 cli command "commit".
    action 6 cli command 'end '.
    Action 7 "INFO: inserted node 1.1.121.1.

    OMIS...

    Event Manager applet remove_inside_node199
    event track State 199
    order cli action 1 'enable '.
    Action 2 cli command "conf t".
    Action 3, command cli "itd session device-group ips_inside.
    Action4 'no node ip 1.1.121.199' cli command
    Action 5 cli command "commit".
    action 6 cli command 'end '.
    Action 7 "INFO: removed the 1.1.121.199 node.

    Event Manager applet add_inside_node199

    199 State event track upward
    order cli action 1 'enable '.
    Action 2 cli command "conf t".
    Action 3, command cli "itd session device-group ips_inside.
    Action 4 cli command "node ip 1.1.121.199.
    Action 5 cli command "commit".
    action 6 cli command 'end '.
    Action 7 "INFO: inserted node 1.1.121.199.

    Using track, can you cannot match on a circuit racetrack pattern.  But, using track syslogs, it would be possible to consolidate these cmdlets to one.  For example:

    Event Manager applet add_inside_node

    event model syslog "TRACK-6-STATE :.*-> to top"

    Action 1.0 regexp ' STATE: ([0-9] +) "" $_syslog_msg "corresponds to the track

    command cli 2.0 action 'enable '.

    Action 3.0, «config t» cli command

    Action 4.0, command cli "itd session device-group ips_inside.

    Action 5.0, command cli "node ip 1.1.121.$track.

    action 6.0 cli command "commit".

    Action 7.0 cli command "end".

    message from syslog to action 8.0 "INFO: inserted node 1.1.121.$track.

  • Problem with external scripts to run

    Hello

    I was wondering if someone can help me, got a problem where the external script is running without problems, the file gets generated and released into the log folder then file disappears as expected.

    When the file disappears, file does not appear to have sent to the BB server. The file has no file extension.

    The customer is 4.40 and the host file is defined by:

    "IP ADDRESS" "Servername" #testip "filename."

    I expect that filename must display the column in Big Brother, but does not...

    All thoughts.

    Concerning

    Col

    What is the format that you use for the log file?

    help of BBPE customer win:

    The first line must begin with the color of the State for the test (usually green, yellow or red). The rest of the file can contain anything; If you click on the color on the screen of Big Brother, you will see the contents of the file. Generally, we recommend that include you the date, time and name of the host on the first line, with the following lines describing the results of the tests, like this:

    color day date [hostname]
    results message
    results message
    ...

    For example:

    Red game 08 21:10:24 1998 [xxx.domain.com]
    blah blah
    blah blah

    We highly recommend that you include the host name on the first line, especially if the client computer uses the DHCP protocol.

    You can change the amount of time before the test results never expire (and the test status shows purple), the substitution of the default on the servers of the display. Place a sign plus (+) and the time, before immediately after the color in the log file. You can express the time in minutes (m), hours (h) or days (d). For example, to have this test does not turn purple for 26 hours:

    Green + 26: Thu 08 21:10:24 1998 [xxx.domain.com]
    blah blah
    blah blah

    Change the expiration time can be useful for scripts that you run only once a day: save the controls, the system checks every day and so on.

    In addition, you can send the status for a test on a different host including the hostname before color, separated by a colon (:). This is useful if you run tests for several hosts from the same client of Big Brother. For example:

    Some.Host.Anywhere:Red Thu 08 21:10:24 1998 [xxx.domain.com]
    blah blah
    blah blah

    This indicates to the server that this status is for some.host.anywhere, not for the current client host.

  • My iPad has been slow and unstable. What can I do if this is caused by a virus from the Internet because that is what I suspect. The problem started after a message like "scripts to run.

    My iPad has been slow and unstable - it actually seems to be hung when I use it. Once I put it, a blue line with four faces (which forms a rectangle or square) appears on the display and moves as he tries to anticipate my next actions or touch on the scree. All started about four days ago while I was downloading of articles in google scholar. A message that reflects something as "run scripts" or "scripts to run" appeared just before the problem started. Please advise on what I can do.

    Try resetting your device. This will not erase your data stored on that device.

    • Press and hold the sleep/wake button
    • Press and hold the Home button
    • Press and hold both buttons until the display turns off and on again with the Apple logo on the subject.

    Alternatively, you can go to settings - general - reset - Reset all settings

    If that doesn't work, restore your device to factory settings. Please note that this will delete the data on your device.

    Take a look this Apple Support article: use iTunes to restore the iPhone, iPad or iPod to factory settings - Apple Support.

  • Several Windows local sql scripts to run automatically.

    Hi Experts, here's my dillemma.

    Oracle DB version: 10G

    Installed in: Sun solaris Sparc Unix machine.

    Customer used in local machine: PLSQL developer version 10

    I'm going to get a set of .sql files every week on my local machine to windows 7 especially recreate tables, insert data, and perform other actions of DB.

    Our project aims to automate the process of sql executions.

    Whatever the State of execution of the 1 file, execution should continue with the rest of the sql files & save errors and other messages.

    But the problem here is

    (1) we don't have access to the Unix machine where DB is installed to write a shell script and run these files.

    (2) we have only customer plsql developer which interfaces with DB.

    My life I worked with scripts Unix & plsql, but not having don't access Unix is a newthing to me & its driving me crazy.

    Please give me advice on how to approach it.

    (1) can use us plsql developer for pickthe local files & run them?

    (2) can write us that all back base program in order to recover and run the local sql files.

    Assumptions:

    I think that PLSQL programming in itself is not a way to access the files stored in the local computer (my system and not the box Pb, in that it is installed).

    Thank you for your time and response.

    Tip:

    use customer sqlplus to connect to db. and run your scripts in the bat file

  • ESXi 5.5 check if the custom script is running

    Hello

    I'm working on a solution, as remote custom for ESXi environments.  The only area that I have a problem, is that I need to check if my (running locally on the ESXi host) shutdown script runs in reality or (to avoid running processes in doubles).

    I know that in the ordinary Linux systems I can do things like (ps to the | grep "test.sh" | grep - v 'grep') or (c - stat %X /proc/ pgdump).  This doesn't seem to work on ESXi.

    Recommendations:

    • This must be run locally on the remote site
      • no access to the vCenter Orchestrator
    • No windows
      • The main system that will control the whole process is Debian
    • Do not install any 3rd party on ESXi hosts
    • Do not recommend N.U.T.S or APCUPSD
    • Must be able to check if the script works not the commands in the script
      • The real script runs several commands at different times

    Test configuration:

    1. Create a loop file in /tmp/test.sh

    #! / bin/sh

    I have = 1

    while [[ $i -le 1000000]]

    do

    echo 'Still running.  Step $i'

    ((i = i + 1))

    fact


    1. Make the file executable
      1. chmod + x /tmp/test.sh
    2. Run the test script
    3. Which can run to verify that the script still works?

    Any help is appreciated.

    Thank you

    B

    Ok.  Spend many hours looking for a way to see who "sh" process to run my script, I gave up and continued in the way of what has suggested Alistar.

    Solution: (linux - dirty way to ensure that only one instance of a shell script is running at a time - Stack Overflow)

    Basically, we create a file locking with the PID on the inside.  If the concurrent process give it a shot, they are arrested.  You can also look in the locking file to find the PID, if you want to force the exit, the newspaper, etc...

    For example

    #!/bin/sh
    LOCKFILE=/tmp/lock.txt
    
    if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
         echo "already running"
         exit
    fi
    
    # Remove the lockfile when process is exited
    trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
         echo $$ > ${LOCKFILE}
    
    #do stuff
    i=1
    while [[ $i -le 1000000 ]]
         do
              echo "Still running.  Step $i"
              let i=i+1
    done
    
    rm -f ${LOCKFILE}
    
  • InDesign script to run on the action?

    Hi, can someone help - is it possible to set up an indesign script to be triggered to perform an action, for example when you export to PDF (instead of manually running the script)? To explain, I have a script that creates a text box to display the size of the indesign document, but if the size of the page change the text box does not update unless you manually run the script again. so I was wondering if it was possible to put the script to run when the document is exported to PDF, so in theory be PDFd with the size of the pages always display up-to-date!

    I approach this issue perspective, as altogether new to the am scripts.

    Thanks in advance for any suggestions.

    Hi Trevor - thank you very much for this - (after a bit of trial and error with changes!) managed to make it work.

    Work of great stuff.

    Thanks again

  • script to run several queries to find/replace

    Working on a big book of ID document (* .indb), I saved dozens of queries to search/replace (named "col01', 'col02' etc.) that I run on 'all documents '. For some reason, I have to run these queries several times a day.

    So I'm wondering if he has, or if someone out there will write: a script that runs these queries one after another. Given the size of the book, it may be necessary to provide the script to pause after each query (before it turns on with the next), but I'm just guessing.

    Any help is very appreciated!

  • Need a script to insert pages with specified master

    Several years ago, someone here (I think that Dave, perhaps Ole) helped me by giving me a few scripts that run when added to a white page (with a specified master page different from the previous page) after each page of a document.

    I had a reformat of emergency of my system and have lost this script I need constantly to works projects. I tried to get here, but that was before the current forum installation (I think about 2 years ago) and I can't find a way to get to the archives.

    If anyone can provide me the code of java script for this or direct me to the older posts on this subject, I would be very grateful.

    And BTW, I use CS4 now (although I don't know the script, I am using was an earlier version).

    Thank you.

    Here: I do not know the original, but I just whipped together for you:

    var doc = app.documents[0];
    var masterNames = doc.masterSpreads.everyItem().name;
    var d = app.dialogs.add({name:"pick a master spread"});
    d.dialogColumns.add().staticTexts.add({staticLabel:"Master Pages:"});
    var dd = d.dialogColumns.add().dropdowns.add({stringList:masterNames});
    if(d.show()){
         var index = dd.selectedIndex;
         d.destroy();
    } else {
         d.destroy();exit();
    }
    var master = doc.masterSpreads.item(index);
    for(var i=doc.pages.length-1;i>=0;i--){
         doc.pages.add(LocationOptions.AFTER,doc.pages[i],{appliedMaster:master});
    }
    

    HTH,

    Substances

  • V21 Firefox cannot find the files if file *.htm used "style windows" path slashes to the java scripts (on Unix, hosting with apache)

    Hello. I find a strange behavior of Firefox v21. If the 'windows' path used *.htm file slashes to the java scripts (on Unix, hosting with apache). Firefox says 404, but other browsers (such as Opera, Chrome, IE10) works properly with this.

    You should use slashes in links so that they work properly in Firefox, otherwise Firefox will escape them that 5% C as you can see if you would them hover in the case of a real link (this is obviously not possible in this case).

  • What are the original applications for the iPhone 6 s. I had to sync to my iPhone 3g to my new 6s in order to maintain my contacts. can someone please send screenshots of an iPhone running 6s with applications shown. I need pages outside the home page.

    What are the original applications for the iPhone 6 s. I had to sync to my iPhone 3g to my new 6s in order to maintain my contacts. Unfortunately, I lost a lot of these new applications. can someone please send screenshots of an iPhone running 6s with applications shown. I need pages other than the home page. Thank you!

    'Stock' apps are part of the installation of iOS and cannot be removed, so there is nothing to verify or prove.

    When you move to a new phone, just need restoring your old backup phone and compatible applications will be synchronized to the new.

  • 6730 b DEATH - only runs connected with no battery

    6730 b DEATH - only runs connected with no battery

    If I insert the battery while it is running connected, the PC will immediately dead.

    Any help on disgnosing what is the problem would be appreciated.

    Logic for me.  Thank you.  I'll post the results once I have buy and install a new battery.

  • Cannot see/Run JCarousel with FireFox

    Cannot see/run JCarousel with Firefox.

    I am able to see the main image and the images over the primary image line; but the javascript code which changes at each successive image does not work.

    I can't run any JCarousel with FireFox. National Geographic is just one example of the most recent which does not work.

    You have quite a few extensions you installed that can cause problems like that (Adblock Plus, Ghostery).

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of your modules is causing your problem (switch to the DEFAULT theme: Tools > Modules > themes).

    • Makes no changes on the start safe mode window.

    See the extensions, themes and problems of hardware acceleration to resolve common troubleshooting Firefox problems and troubleshooting questions with plugins like Flash or Java to solve common Firefox problems

    • If you have many extensions then you first activate half test extensions that half the problem.

    Continue to divide the bad half that still has the question until you find that one is causing it.

  • final cut pro could run fast with macBook pro mid 2012?

    My MacBook pro (13-inch, mid-2012). Proc. 2.5 GHz intel Core i5. Memory 16GB 1600 MHz DDR3, startup disk Macintosh HD, 4000 1536 MB video card, could run fast with final cut pro X?

    the specifications of your look familiar to mine... (MacMini2012)

    works like charm IF you use external drives for media...

    recommend as 'work horse' a SSD, usb3 connected, position 250 GB = ~ €120

    very small, very lightweight, blazing fast

Maybe you are looking for