::cisco::eem::event_register_syslog pattern "CPURISINGTHRESHOLD"
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
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
}
if [catch {cli_exec $cli1(fd) "show proc cpu sorted 5min"} _cli_result] {
error $_cli_result $errorInfo
}
set lines 0
set _ts "$_cli_result"
while {$_ts != ""} {
if {[regexp -indices "\n" $_ts _loc] == 0} {
set line $_ts
set _ts ""
} else {
set _mstart [lindex $_loc 0]
set _mend [lindex $_loc 1]
if {$_mstart == 0} {
set line ""
} else {
set line [string range $_ts 0 [expr $_mstart - 1]]
}
set _ts [string range $_ts [expr $_mend + 1] end]
}
if {$lines > 25} {
break
}
append output $line
incr lines
}
set mail_pre "Mailservername: $_email_server\n"
append mail_pre "From: $_email_from\n"
append mail_pre "To: $_email_to\n"
append mail_pre
append mail_pre "Subject: CPU Alert\n\n"
append mail_pre "$output\n\n"
set mail_msg [uplevel #0 [list subst -nobackslashes -nocommands $mail_pre]]
if [catch {smtp_send_email $mail_msg} result] {
error $result $errorInfo
}
# Close open cli before exit.
if [catch {cli_close $cli1(fd) $cli1(tty_id)} result] {
error $result $errorInfo
}
Blogs and organic groups at http://www.ccie.net
Received on Fri Mar 18 2011 - 16:15:34 ART
This archive was generated by hypermail 2.2.0 : Fri Apr 01 2011 - 06:35:41 ART