02-03-2015 03:34 AM
Hi , I have Cisco ASR9k running with NAT44 service
I have some numbers to monitor that will be extracted using show | include
I want to write an EEM script that will take an action if this value exceeds a certain value
As well , can I draw these value using show with include option ?
Thanks
04-16-2015 06:49 AM
I love it.
Thank you!
07-27-2015 04:56 AM
Hi Jospeh
Am trying to run my previous script and am getting errors
RP/0/RSP0/CPU0:ASR1#event manager run CGN1.tcl
When I try to remove the policy command as below
RP/0/RSP0/CPU0:ASR1(config)#no event manager policy CGN1.tcl username EEMUSER persist-time infinite
Am getting noticed that the policy is not registered
!!% Embedded Event Manager configuration: No policy CGN1.tcl registered
Any ideas how to resolve it ?
BR,
Mohammad
07-27-2015 07:12 AM
I think you need a "commit" in between those commands.
07-28-2015 12:29 AM
Yes I have tried to commit before but strange it keep gives me errors !
BR,
Mohammad
07-28-2015 06:53 AM
What errors? The error above is what I'd expect if the policy hadn't been registered with the EEM server yet.
07-28-2015 07:04 AM
I will give it another try and send you the error I got
By the way Joseph if you can help me with something also related to EEM
If I wanted to track configuration changes (actually made) , If I configured the syslog pattern like SYS-5-CONFIG_I , that can be generated If I entered and exit from the configuration mode , so it will not be that value ?
And should I go with archive ?
Thanks for your continuous help
BR,
Mohammad
07-28-2015 08:11 AM
Please start a new thread for a new question. This thread is way too long, and it's difficult to navigate at this point.
07-30-2015 02:21 AM
RP/0/RSP0/CPU0:UM-HQ1-CGN-3G-NAT1(config)#no event manager policy CGN1.tcl username EEMUSER persist-time infinite
RP/0/RSP0/CPU0:UM-HQ1-CGN-3G-NAT1(config)#commit
Thu Jul 30 12:15:09.918 AST
% Failed to commit one or more configuration items during a pseudo-atomic operation. All changes made have been reverted. Please issue 'show configuration failed' from this session to view the errors
RP/0/RSP0/CPU0:UM-HQ1-CGN-3G-NAT1(config)#show configuration failed
Thu Jul 30 12:15:17.042 AST
!! SEMANTIC ERRORS: This configuration was rejected by
!! the system due to semantic errors. The individual
!! errors with each failed configuration command can be
!! found below.
no event manager policy CGN1.tcl username EEMUSER
!!% Embedded Event Manager configuration: No policy CGN1.tcl registered
end
07-30-2015 07:12 AM
Again, this shows that the policy wasn't previously registered. If you run "show event manager policy registered" you should not see it. You need to have the policy successfully registered and committed before you can remove it.
08-03-2015 02:38 AM
Hi Joseph
Thanks for the update
Usually , I configure the command vent manager policy CGN1.tcl username EEMUSER persist-time infinite to get the policy registered
The policy is not registered
Mon Aug 3 11:40:17.925 AST
No. Class Type Event Type Trap Time Registered Name
1 script user timer cron Off Thu Mar 26 18:49:31 2015 tftp-backup-UM-HQ1-CGN-3G-NAT1.tcl
cron entry {0 10 * * *}
nice 0 queue-priority normal maxrun 600.000 scheduler rp_primary Secu none
persist_time: 4294967295 seconds, username: EEMUSER
04-28-2015 03:07 AM
Hi Joseph
I have tried to send mail from IOS and it worked fine , the same script I converted to IOS XR but it's not working !
::cisco::eem::event_register_syslog pattern {%PKT_INFRA-LINK-5-CHANGED : Interface GigabitEthernet0/0/0/1, changed state to Administratively Down}
# This EEM tcl policy was generated by the EEM applet conversion
# utility at http://www.marcuscom.com/convert_applet/
# using the following applet:
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
set mail_pre "Mailservername: mail.com\n"
append mail_pre "From: mail@mail.com\n"
append mail_pre "To: mail@mail.com\n"
append mail_pre "Subject: ALERTXR\n\n"
set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]
if [catch {smtp_send_email $mail_msg} result] {
error $result $errorInfo
}
04-28-2015 07:57 AM
The script is fine. Just make sure your SMTP server allows email from your router. And check with a packet capture tool to see what errors you get.
You should also consider starting new threads for your issues. This one is getting very hard to follow.
04-28-2015 02:46 PM
Thanks Joseph and sorry for the complexity
The mail server am using is the same am using for the working IOS EEM applet , could this be due to a missing file on the IOS XR ?
BR,
Mohammad
04-29-2015 08:14 AM
You haven't posted the actual error, but I doubt it's due to a missing file. I recommend the packet capture option to see what the SMTP dialog looks like between the router and server.
Also, I have assumed that since you obfuscated this script, that you do, in fact, have a body part of your message.
04-21-2015 06:02 AM
Hi Joseph
Thanks for your continuous help
I uploaded the below script to my XR box
::cisco::eem::event_register_none
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_write $cli1(fd) "run attach 0/1/CPU0"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_read_pattern $cli1(fd) "#"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_write $cli1(fd) "show_nat44_stats"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_read_pattern $cli1(fd) "#"} _cli_result] {
error $_cli_result $errorInfo
}
set output $_cli_result
if [catch {cli_exec $cli1(fd) "exit"} _cli_result] {
error $_cli_result $errorInfo
}
foreach line [split $output "\n"] {
set line [string trim $line]
regsub -all {\s+} " " $line line
if { [regexp {^([0-9]+) ([0-9]+)\([0-9]+%\) ([0-9]+)} $line -> core sessions users] } {
action_syslog msg "Core: $core, Sessions: $sessions, Users: $users" }
}
# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result
But nothing appeared on the screen when I ran the command run event manager CGN1.tcl
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