cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4019
Views
0
Helpful
6
Replies

eem action file -no write to file possible

Martin Ermel
VIP Alumni
VIP Alumni

I am trying to write an EEM applet that reacts on a certain syslog message and writes the status of an alarm-contact (which is part of the Cisco IE4000) into a file. Later a second EEM applet shall read  from that file and based on the content execute some commands …. or not.

It seems my problem is the "file descriptor" part but I cannot find any documentation that describes in detail how to set and use the file descriptor..

This is what I have:

  

event manager applet Contact_2

 event syslog pattern "PLATFORM_ENV-1-EXTERNAL_ALARM_CONTACT_CLEAR: Alarm cleared: external alarm contact 2"

 action 100 cli command "enable"

 action 200 file open $fh flash:Contact2_stat.txt w

 action 210 file write $fh "OPEN"

 action 220 file close $fh

 action 300 cli command "end"

 

I have also defined these event manager environment variables:

 event manger environment $fh flash:/Contact2_stat.txt

event manger environment fh flash:/Contact2_stat.txt

 

The error I get is the following (complete debug is attached)

[…]

Mar 30 10:14:45.423: %HA_EM-7-FMPD_FILE_WRITE: fh_stmt_file: failed to write to fd flash:/Contact2_stat.txt : invalid file descriptor

Mar 30 10:14:45.423: %HA_EM-3-FMPD_ERROR: Error executing applet Contact_2 statement 210

[…]

 

The file exists in flash: but it is empty.

What could be the issue ?

2 Accepted Solutions

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

The file actions use variable names and not dereferenced variable values.  So your applet should be:

event manager applet Contact_2

 event syslog pattern "PLATFORM_ENV-1-EXTERNAL_ALARM_CONTACT_CLEAR: Alarm cleared: external alarm contact 2"

 action 200 file open fh flash:Contact2_stat.txt w

 action 210 file write fh "OPEN"

 action 220 file close fh

View solution in original post

This is working for me with bootflash:file on 7.3.  I get content within the file.  Not sure if you're within a VDC.  I am on the "bare metal" and I did not have an issue.

View solution in original post

6 Replies 6

Joe Clarke
Cisco Employee
Cisco Employee

The file actions use variable names and not dereferenced variable values.  So your applet should be:

event manager applet Contact_2

 event syslog pattern "PLATFORM_ENV-1-EXTERNAL_ALARM_CONTACT_CLEAR: Alarm cleared: external alarm contact 2"

 action 200 file open fh flash:Contact2_stat.txt w

 action 210 file write fh "OPEN"

 action 220 file close fh

Joe, that did the trick - thanks a lot ! 

Joe, is there any change to NXOS 7.3  for the file path/filename format?


!Command: show running-config eem
!Time: Sun May 21 01:53:27 2017

version 7.3(0)D1(1)
event manager applet eem.ping
  event syslog occurs 1 period 2 pattern ".*VSHD-5-VSHD_SYSLOG_CONFIG_I.*"
  action 200 file open fh flash:ping_result.txt w  
  action 210 file write fh SUCCESS   
  action 220 file close fh
 
2017 May 21 01:53:34 RP-TEAM1 %VSHD-5-VSHD_SYSLOG_CONFIG_I: Configured from vty by admin on 10.66.254.180@pts/2
2017 May 21 01:53:35 RP-TEAM1 eem_policy_dir: fh_stmt_file: failed to open file /flash/ping_result.txt : No such file or directory

Nexus# dir
       4096    Jul 12 05:32:15 2016  scripts/
       4096    Jul 12 05:32:22 2016  virtual-instance/

I believe on NX-OS, it would be be bootflash:file.  I don't think an NX-OS device has a flash: file system.

I've tried following combination and still doesn't work.

  • filename
  • flash:filename
  • bootflash:filename
  • created flash directory on the bootflash

With the bootflash:filename, I don't get any error message but no file was created on the bootflash. I run all possible debug related to the eem but couldn't see any clue in the output messages.

This is working for me with bootflash:file on 7.3.  I get content within the file.  Not sure if you're within a VDC.  I am on the "bare metal" and I did not have an issue.

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: