ip sla 1
icmp-echo 212.158.166.234
timeout 500
frequency 3600
ip sla schedule 1 life forever start-time now
track 1 rtr 1 reachability
event manager environment _eserv 192.168.1.10
event manager environment _admin admin@localname.com
event manager environment _rep reports@localname.com
event manager applet host_is_down
event track 1 state down
action 1 mail server "$_eserv" to "$_admin" from "$_rep" subject "Habrahabr is not pinging"
event manager applet host_is_up
event track 1 state up
action 1 mail server "$_eserv" to "$_admin" from "$_rep" subject "Habrahabr is pinging now"
action 1 mail server "$_mail_smtp" to "$_mail_rcpt" from "$_info_routername@$_mail_domain" subject "Interface state change" body "\015\012$_syslog_msg"
Router(config)# archive
Router(config-archive)# path flash:archive_config
Router(config-archive)# maximum 5
Router(config)#event manager environment filename archive_config
Router#copy tftp flash
Address or name of remote host []? 192.168.1.2
Source filename []? archive.tcl
Destination filename [archive.tcl]?
Accessing tftp://192.168.1.2/archive.tcl...
Loading archive.tcl from 192.168.1.2 (via GigabitEthernet0/0): !
[OK - 1308 bytes]
1308 bytes copied in 0.156 secs (8385 bytes/sec)
Router(config)#event manager directory user policy flash:
Router(config)#event manager policy archive.tcl
::cisco::eem::event_register_syslog pattern ".*%SYS-5-CONFIG.*"
if {![info exists filename]} {
set result "Policy cannot be run variable filename has not been set."
error $result $errorInfo
}
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
if [catch {cli_open} result] {
puts stderr $result
exit 1
} else {
array set cli1 $result
}
if [catch {cli_exec $cli1(fd) "en"} result] {
puts stderr $result
exit 1
}
set showarchive [cli_exec $cli1(fd) "show archive"]
if { [regexp “Archive feature not enabled” $showarchive] } {
puts stderr $showarchive
exit 1
}
set lines [split $showarchive "\n"]
foreach line $lines {
set result [regexp {<- Most Recent} $line ]
if {$result != 0} {
set result1 [regexp {^\s+\d+\s+(.+)-(\d+)\s+<-} $line -> path extension]
set output [cli_exec $cli1(fd) "show archive config differences system:/running-config flash:$filename-$extension"]
if { [regexp "!No changes were found" $output] } {
break
} elseif { [regexp "Error: Could not open file" $output] } {
cli_exec $cli1(fd) "archive config"
break
}
else {
cli_exec $cli1(fd) "archive config"
break
}
}
}
Source: https://habr.com/ru/post/91879/
All Articles