01-07-2016 09:25 AM
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 ?
Solved! Go to Solution.
01-08-2016 08:45 AM
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
05-22-2017 06:22 AM
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.
01-08-2016 08:45 AM
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
01-09-2016 05:24 PM
Joe, that did the trick - thanks a lot !
05-20-2017 08:52 PM
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/
05-21-2017 12:21 PM
I believe on NX-OS, it would be be bootflash:file. I don't think an NX-OS device has a flash: file system.
05-21-2017 04:25 PM
I've tried following combination and still doesn't work.
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.
05-22-2017 06:22 AM
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.
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: