Disable optional features on high CPU load

From CT3

Jump to: navigation, search

The applet monitors the average one minute CPU load on the router (using the cpmCPUTotal1min SNMP variable) and disables optional features when the CPU load exceeds predefined value. The sample applet disables WCCP when the CPU load exceeds 75 and re-enables it when the CPU load drops below 40%. By editing the EEM applet code, you could change the thresholds or enable/disable other optional Cisco IOS features.

Author

Submitted by an anonymous reader of the Cisco IOS hints blog

Source code

The disable_wccp applet disables WCCP when the 1-minute utilization of the main CPU exceeds 75%.

event manager applet disable_wccp 
 ! --- 1.3.6.1.4.1.9.9.109.1.1.1.1.4.1 gives the cpu utilization using 1 min interval 
 ! --- trigger event when cpu utilization hits 75% and starts monitoring (re-arms) 
 ! --- again when it drops below 40% 
 ! --- SNMP polling interval is set to 60 secs 
 event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.4.1 get-type exact entry-op ge entry-val 75 →
  exit-op le exit-val 40 poll-interval 60 
 ! --- logs a message 
 action 101 syslog priority notifications msg "Disabling WCCP due to prolonged CPU spikes." 
 ! --- disable wccp globally, this is static - you have to know the wccp svc id 
 action 102 cli command "enable" 
 action 103 cli command "config t" 
 action 104 cli command "no ip wccp 91" 
 action 105 cli command "end" 

If you want to send an e-mail notification when the WCCP has been disabled, append the following to the above applet (see the Send e-mail from EEM applet page for details):

action 200 cli command "show process cpu 1min sorted" 
action 201 info type routername
action 202 mail server "$_mail_smtp" to "$_mail_rcpt" from "$_info_routername@$_mail_domain" →
 subject "Prolonged CPU Spikes" body "$_cli_result" 

The enable_wccp applet re-enables WCCP when the 1-minute utilization of the main CPU falls below 40%:

event manager applet enable_wccp 
 ! --- 1.3.6.1.4.1.9.9.109.1.1.1.1.4.1 gives the cpu utilization using 1 min interval 
 ! --- trigger event when cpu utilization is below 40% and starts monitoring (re-arms) 
 ! --- again when it rises to 75% 
 ! --- SNMP polling interval is set to 60 secs 
 event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.4.1 get-type exact entry-op le entry-val 40 →
  exit-op ge exit-val 75 poll-interval 60 
 ! --- logs a message 
 action 101 syslog priority notifications msg "Re-enabling WCCP" 
 ! --- re-enable wccp globally, this is static - you have to know the wccp svc id and redirect-list 
 action 102 cli command "enable" 
 action 103 cli command "config terminal" 
 action 104 cli command "ip wccp 91 redirect-list 101" 
 action 105 cli command "end"

Related configuration

The Send e-mail from EEM applet page describes the environment variables used in the mail command.

Personal tools

CT3

Main menu