09-29-2015 08:53 AM
Hello All,
I have created an EEM script in NX-OS(nexus 6k - 6.0.2) that is returning command failures in the accounting log. Below is the script I am using:
event manager applet python
event syslog pattern "%PFMA-2-FEX_STATUS: Fex .* is online"
action 1.0 event-default
action 2.0 cli python /scripts/fex_ports_disable.py $_syslog_msg
action 3.0 syslog priority informational msg fex ports down
The idea is that this syslog message will execute a python script that is stored in the /scripts/ folder of the bootflash. I am getting the following error in the accounting log:
Sat Jan 19 15:37:30 2013:type=update:id=vsh.9870:user=__eemuser:cmd=python bootflash:/scripts/fex_ports_disable.py (FAILURE)
is there something special that needs to be done in order to allow EEM to pass this variable and run the python script?
Thanks,
Justin
09-30-2015 09:16 PM
Calling a script from an EEM applet wasn't officially supported until NX-OS 7.x. It has been known to work prior to that, though. The only thing I see that could be problematic is that the syslog message will contain spaces. You might try seeing if a simple Python script can be invoked in this version of NX-OS.
10-01-2015 05:24 AM
So we are able to successfully call the python script from within NX-OS. It just appears to be an issue with getting EEM to wrap the syslog message into the $_syslog_msg variable. When we invoke the python script manually like below, it works successfully.
python fex_ports_disable.py %NOHMS-2-NOHMS_ENV_FEX_ONLINE: FEX-100 On-line
There is logic in the python script to regexp the syslog message for the fex #, and we have tested this.
Do you have any ideas or recommendations on how we can get the syslog message to be set inside the $_syslog_msg variable, or is there another built-in variable that I could send to the python script?
10-01-2015 07:57 AM
Did you test invoking the script from EEM without arguments? I have no doubt it works manually. I was suggesting you try a simpler test from EEM to see if you can run a Python script at all. As I said, no testing of Tcl/Python execution out of EEM was done until 7.0. I know there have been bugs in the past with this. I do know it's working in 7.x code.
10-01-2015 11:53 AM
Yes, we did..We also changed the EEM script to invoke just the python script like below:
action 2.0 cli python /scripts/fex_ports_disable.py %NOHMS-2-NOHMS_ENV_FEX_ONLINE: FEX-100 On-line
This did in fact work, we could just not get the syslog message to send as a variable correctly.
With your suggestion, I am going to switch the testing to a 5548 running 7.0.6 code and see if we are able to obtain better results.
Thanks!
10-01-2015 12:37 PM
Hmmm, interesting. Can you paste the output of "show event manager event-types"?
10-01-2015 01:13 PM
Hi Joe,
outputs are below:
usipn-moli19t-sn6klab1# show event manager event-types
Name : oir
Description : OIR event
Event Parameters : devicetype, eventtype, devicenum
Publisher : Platform Manager
Default Action : None
Name : fanabsent
Description : Fan Absent Event
Event Parameters : devicenum, time
Publisher : Platform Manager
Default Action : None
Name : fanbad
Description : Fan Bad Event
Event Parameters : devicenum, time
Publisher : Platform Manager
Default Action : None
Name : memory
Description : Memory Alerts
Event Parameters : memstate
Publisher : Platform Manager
Default Action : None
Name : temperature
Description : Temperature Sensor Event
Event Parameters : modnum, sensornum, major_minor
Publisher : Platform Manager
Default Action : Shutdown on major temperature threshold
Name : allfanabsent
Description : All Fan Absent Event
Event Parameters : devicenum, time
Publisher : Platform Manager
Default Action : None
Name : snmp
Description : SNMP MIB object monitoring
Event Parameters : param1, param2
Publisher : SNMP
Default Action : None
Name : cli
Description : EEM CLI command filter
Event Parameters : command
Publisher : CLI events publisher
Default Action :
Name : cli
Description : EEM CLI command filter
Event Parameters : command
Publisher : CLI events publisher
Default Action :
Name : link_flap
Description : Link Flaps
Event Parameters : interface, cause
Publisher : Ethernet Port Manager
Default Action : Error Disable the port
Name : storm_control
Description : Traffic on a port exceeds configured thresholds
Event Parameters : interface, cause
Publisher : Ethernet Port Manager
Default Action : None
Name : debug_1
Description : Internal event used by apps to indicate faults.
Event Parameters : interface, cause
Publisher : Ethernet Port Manager
Default Action : None
Name : debug_2
Description : Internal event used by apps to indicate faults.
Event Parameters : interface, cause
Publisher : Ethernet Port Manager
Default Action : None
Name : debug_3
Description : Internal event used by apps to indicate faults.
Event Parameters : interface, cause
Publisher : Ethernet Port Manager
Default Action : None
Name : debug_4
Description : Internal event used by apps to indicate faults.
Event Parameters : interface, cause
Publisher : Ethernet Port Manager
Default Action : None
Name : track
Description : Track object
Event Parameters : object, state
Publisher : Object Tracking Manager
Default Action : none
Name : counter
Description : Named Counter Event
Event Parameters : counter_name, counter_value
Publisher : MVSH
Default Action : None
10-01-2015 01:16 PM
This is what I suspected. You have the bug where the syslog ED exports the message in the variable $command instead of $_syslog_msg. Change $_syslog_msg to $command and see if that helps.
10-02-2015 04:52 AM
That definitely worked on getting the syslog message into the variable, thanks Joe!
However, I am still getting failures on the execution in the accounting log. Could this partly be from what you spoke of earlier with the python and EEM not being validated yet?
Tue Jan 22 11:47:11 2013:type=update:id=vsh.27607:user=__eemuser:cmd=python bootflash:/fex_ports_disable.py %NOHMS-2-NOHMS_ENV_FEX_ONLINE: FEX-100 On-line (FAILURE)
Tue Jan 22 11:47:11 2013:type=update:id=vsh.27607:user=__eemuser:cmd=syslog priority informational msg fex ports down (SUCCESS)
10-02-2015 05:53 AM
Yes, it could be. I haven't found any discussion of such a failure internally.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide