06-23-2016 10:49 AM
router#sh run | sec event
event manager session cli username "user" privilege 15
event manager applet syslog_redirect
event timer watchdog time 3600
action 1.0 cli command "term len 0"
action 2.0 cli command "show log | redirect ftp://10.10.10.10/log.txt"
The above is my current configuration and is working to export the local log buffer to a remote server. I would like to be able to append the current device date/time to the log.txt file. Some other forum posts indicate that there are global variables I can call, such as $t (as seen in the following post):
https://supportforums.cisco.com/discussion/11376731/automatic-backup-using-eem
I was hoping to find something like an "action x.x info type datetime", but there doesn't appear to be anything like that. I tried using the $t variable, but it gives me the following output:
Jun 23 10:48:46.668 GMT: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: t
Jun 23 10:48:46.668 GMT: %HA_EM-3-FMPD_ERROR: Error executing applet syslog_redirect statement 2.0
06-23-2016 11:54 AM
Hi
I've done a lot of EEM script for some troubleshooting to get logs and even on cisco documentation, as far as I know, there isn't any time variable to use. The only way would be to use the command:
sh clock | append flash:test.txt
The variable $t (for date/time) and $h for hostname are used on backup stuff, I mean archive config.
Thanks
PS: Please don't forget to rate and mark as correct answer if this solved your issue
06-23-2016 12:54 PM
Thank you for the clarification, I was kind of thinking that was the case.
So is there any way to create an environmental variable I can call in an action, or another pre-defined variable? Is there any other way to do this, or is it just not possible?
06-23-2016 01:06 PM
You can do some things by using IOS.sh shell capabilities.
Here a doc if you're interested :
http://www.cisco.com/c/en/us/td/docs/ios/netmgmt/configuration/guide/Convert/IOS_Shell/nm_ios_shell.html
You can even use tcl scripts.
But in your case it would be simple (based on your eem script), to just add the show clock action.
Thanks
PS: Please don't forget to rate and mark as correct answer if this solved your issue
06-23-2016 04:19 PM
Ok, so I was successfully able to open the IOS.sh shell and define a variable $TIME which is just "show clock". It appears that I can't disable the shell and still call the variable, though. I will test this out tomorrow and validate that it works as expected.
One more thing -- what is the impact of enabling the shell on a device? Is there increased cpu/memory utilization due to the shell running in the background, or?
I'd be enabling this on a device which will handle voice traffic, and don't want to cause any additional resource usage if I don't have to. If there is a resource change, it may be a toss up between being able to do the original redirect vs. reliable calls.
06-23-2016 05:20 PM
For sure you will consume a little bit more cpu/process like any other process but I've never experienced issue of traffic dropping in my cases.
Thanks
06-28-2016 09:37 AM
Unfortunately this is not working. The variable I created simply shows up as "show clock" when it is run.
06-28-2016 05:34 PM
Usually, we use IOS shell when you want to do some stuff on live by using global variables, cat and grep functionality. It is useful when you don't have any linux machine and want to do live some stuff.
The built-in function of IOS.sh are accessible from EEM (cisco doc said EEM version 4). I've never used it in that way.
In you case, doing the show clock | append will be easier.
Thanks
PS: Please don't forget to rate and mark as correct answer if this solved your issue
09-14-2018 08:18 AM
When I try your solution, the device will just saying
ERROR: % Invalid input detected at '^' marker.
fight after the c of the sh clock.
It doesn't seem like the OS understand that I want to append the time stamp onto the output file.
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