Saturday, March 24, 2012

Cisco EEM script

An EEM script to capture which process is causing CPU spike when CPU usage reach 75% and email noc with the result - this is for 7600

service internal
event manager applet High_CPU
event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.6 get-type next entry-op ge entry-val 75 exit-time 10 poll-interval 60
action 0.1 syslog msg "CPU Utilization is high"
action 0.2 cli command "enable"
action 0.4 cli command "show log | append sup-bootdisk:CPU_Profile.txt"
action 0.5 cli command "show process cpu sorted | append sup-bootdisk:CPU_Profile.txt"
action 0.6 cli command "show interfaces | append sup-bootdisk:CPU_Profile.txt"
action 1.1 cli command "configure terminal"
action 1.2 cli command "profile 40100FB0 443F7FFF 10"
action 1.3 cli command "profile start"
action 2.3 syslog msg "Entering TCLSH"
action 2.4 cli command "tclsh"
action 2.5 cli command "after 240000"
action 2.6 cli command "exit"
action 2.9 syslog msg "Exiting TCLSH"
action 3.0 cli command "profile stop"
action 3.1 cli command "show profile terse | append sup-bootdisk:CPU_Profile.txt"
action 3.2 cli command "clear profile"
action 3.3 cli command "unprofile all"
action 3.4 cli command "more sup-bootdisk:CPU_Profile.txt"
action 3.5 mail server "IP of SMTP server" to "noc@xxx.com" from "noc@xxx.com" subject "CPU Utilization is high" body "$_cli_result"
action 4.1 syslog msg "Finished logging information to sup-bootdisk:CPU_Profile.txt..."
action 4.2 cli command "end"


Reference:
Troubleshooting High CPU Utilization Due to Interrupts
Embedded Event Manager 1.0
EEM scripts examples
Cisco IOS Embedded Event Manager Version 2.4 Expanded Capabilities and New Interfaces
Writing Your First EEM Applet
Writing Embedded Event Manager Policies Using Tcl

1 comment:

  1. you can't apply
    action 1.2 cli command "profile 40100FB0 443F7FFF 10"

    to everyone , this depends on the output of show region and also of the start and end of the main:text

    ReplyDelete