03-12-2013 03:34 AM
Hello Community,
Can someone please show me how to add to the following EEM applet so as to add more ip addresses. I would like to add 172.7.7.1, 192.168.0.1, 10.1.1.1
event manager applet pingall
action 1.1 cli command "enable"
action 1.2 cli command "ping 141.231.45.133"
Cheers
Carlton
03-12-2013 03:39 AM
Community,
Ultimately, I would like to have the results of the ping appear in the cli.
Regards
Carlton
03-12-2013 06:42 AM
Depends on your version of code. With EEM 3.0 you can do:
event manager environment hosts 141.231.45.133 10.1.1.1 11.1.1.1
event manager applet pingall
event none
action 1.0 cli command "enable"
action 2.0 foreach host $hosts
action 3.0 cli command "ping $host"
action 4.0 append results $_cli_result
action 5.0 end
action 6.0 puts $results
03-12-2013 08:09 AM
Joseph,
Thanks for that mate. I'm going to test it out now.
In the meantime, can you tell me what level of code the applet won't work with?
Also, can you tell me what codes won't show event manager version output?
Cheers
Carlton
03-12-2013 08:42 AM
This applet requires EEM 3.0 or higher. To figure out exactly what version your device supports, see:
https://supportforums.cisco.com/docs/DOC-8799
That article covers all of the tips and tricks to figure out the version even if the "show event manager version" is not supported. That said, if "show event manager version" is not supported, then you don't have EEM 3.0.
03-12-2013 08:56 AM
Joseph,
I converted the EEM Applet to Tcl using conversion tool here.
::cisco::eem::event_register_none
#
# This EEM tcl policy was generated by the EEM applet conversion
# utility at http://www.marcuscom.com/convert_applet/
# using the following applet:
#
# event manager environment hosts 10.36.36.225 10.36.36.227 10.50.131.34
# event manager applet pingall
# event none
# action 1.0 cli command "enable"
# action 2.0 foreach host $hosts
# action 3.0 cli command "ping $host"
# action 4.0 append results $_cli_result
# action 5.0 end
# action 6.0 puts $results
#
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
if [catch {cli_open} result] {
error $result $errorInfo
} else {
array set cli1 $result
}
if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {
error $_cli_result $errorInfo
}
foreach host "host" {
if [catch {cli_exec $cli1(fd) "ping $host"} _cli_result] {
error $_cli_result $errorInfo
}
append results $_cli_result
}
puts $results
# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result
However, when I issue the command:
'event manager run pingall', I get the message
Translating "host"...domain server (255.255.255.255)
% Unrecognized host or address, or protocol not running.
Any ideas?
03-12-2013 09:14 AM
Hi Carlton,
The issue with the foreach loop. The "host" list is a string but needs to be a variable, probably something like this should take care of it:
foreach host $hosts {
if [catch {cli_exec $cli1(fd) "ping $host"} _cli_result] {
error $_cli_result $errorInfo
}append results $_cli_result
}
Disclaimer: Not tested.
Mike
03-12-2013 09:26 AM
Mike
Going to try it now...
03-12-2013 09:46 AM
Hi Mike,
The script doesn't work. :-(
03-12-2013 09:48 AM
What error do you get? You need to make sure you've done:
event manager environment hosts HOST_LIST
Where HOST_LIST is a space-separated list of IP addresses to ping.
03-12-2013 10:00 AM
Mike I amended the script as follows:
::cisco::eem::event_register_none
#
# This EEM tcl policy was generated by the EEM applet conversion
# utility at http://www.marcuscom.com/convert_applet/
# using the following applet:
#
# event manager environment hosts 10.36.36.225 10.36.36.227 10.50.131.34
# event manager applet pingall
# event none
# action 1.0 cli command "enable"
# action 2.0 foreach host $hosts
# action 3.0 cli command "ping $host"
# action 4.0 append results $_cli_result
# action 5.0 end
# action 6.0 puts $results
#
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
if [catch {cli_open} result] {
error $result $errorInfo
} else {
array set cli1 $result
}
if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {
error $_cli_result $errorInfo
}
foreach host $hosts {
if [catch {cli_exec $cli1(fd) "ping $host"} _cli_result] {
error $_cli_result $errorInfo
}
append results $_cli_result
}
puts $results
# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result
03-12-2013 10:10 AM
That first line of my sample needs to be configured under config t mode:
event manager environment hosts 10.36.36.225 10.36.36.227 10.50.131.34
That defines the hosts to ping.
03-12-2013 04:14 PM
Hi Joseph sorry it's taken so long to respond,
Anyway are you saying that the following would work
event manager applet pingall
event none
action 0.5 conf t "event manager environment hosts 10.36.36.225. 10.36.36.227"
action 1.0 cli command "enable"
action 2.0 foreach host $hosts
action 3.0 cli command "ping $host"
action 4.0 append results $_cli_result
action 5.0 end
action 6.0 puts $results
Cheers
Sent from Cisco Technical Support iPad App
03-12-2013 04:36 PM
Hi Carlton,
No, Joe is saying the following would work with EEM 3.0 or later:
event manager environment hosts 10.36.36.225. 10.36.36.227
event manager applet pingall
event none
action 1.0 cli command "enable"
action 2.0 foreach host $hosts
action 3.0 cli command "ping $host"
action 4.0 append results $_cli_result
action 5.0 end
action 6.0 puts $results
Or the following would work with any version of EEM that supports Tcl:
event manager environment hosts 10.36.36.225. 10.36.36.227
event manager directory user policy
event manager policy
For the applet, the foreach command was introduced in EEM 3.0, so that requires EEM 3.0 or later. In both cases, you have to define the environment variable "hosts" so that the policy can use it.
Mike
03-13-2013 02:32 AM
Mike, apologies for late response - I'm in England.
Anyway, that appears to be working, however the script will only ping the last addres 10.36.36.227. Is there any reason why it won't ping 10.36.36.225?
Cheers
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