EEM Script on Nexus 7000 Switches to Monitor CPU Utilization

Document

May 27, 2011 5:53 AM
May 27th, 2011

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

Introduction

This document provides a sample configuration for Embedded Event Manager (EEM) script on Cisco Nexus 7000 Series Switches to monitor the CPU utilization. EEM scripts have been used to automate common diagnostics and troubleshooting scenarios that occur on your device based on network events.

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

Prerequisites

Requirements

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} Make sure that you meet these requirements before you attempt this configuration.


  • Have a basic knowledge of configuration on Nexus 7000 Series Switches.
  • Have a basic understanding of Embedded Event Manager (EEM) scripts.


Components Used


The information in this document is based on the Nexus 7000 Series NX-OS devices, started with a cleared (default) configuration. Before using this configuration make sure that you understand the potential impact of any command.

Configure

In this section, you are presented with EEM script configuration to monitor the Nexus 7000 CPU utilization, once it gets above a pre-defined threshold (in this example we use 50%) it will start to execute the commands. The output of the commands will get written to the bootflash which has the information gathered during the period of high CPU utilization.


/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} From this output we can diagnose what causes the CPU to jump up periodically. This EEM script should be configured in the default VDC (virtual device context). It will capture “show proc cpu sort” output in each VDC and write the files to bootflash.

Configuration


This document uses this EEM Script configuration.

Steps:

  1. Create and register the applet with EEM and enter applet configuration mode.
  2. Enter the command to trigger an event based on SNMP object identifier (OID) cross the entry threshold.
  3. Configure the action statements which trigger the action.


/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

Sample configuration given below,

switch(config)#event manager applet highcpu


switch(config-applet)#event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.6.1 get-type exact entry-op ge entry-val  50 poll-interval 1


switch(config-applet)#action 0.1 syslog msg High CPU DETECTED "show process cpu sort" written to  bootflash:highcpu.txt


switch(config-applet)#action  0.2 cli enable


switch(config-applet)#action  0.3 cli show process cpu sort >> bootflash:highcpu.txt


switch(config-applet)#action  0.4 cli show process cpu hist >> bootflash:highcpu.txt


switch(config-applet)#action  0.5 cli switchto vdc Core


switch(config-applet)#action  0.6 cli show process cpu sort >> bootflash:highcpu_Core.txt


switch(config-applet)#action  0.7 cli exit


switch(config-applet)#action  0.8 cli switchto vdc Distribution


switch(config-applet)#action  0.9 cli show process cpu sort >> bootflash:highcpu_Dist.txt


switch(config-applet)#action  1.0 cli exit

Output

The output of the commands will be stored in three separate files in bootflash.


The three files will be:


bootflash:/highcpu.txt

bootflash:/vdc_2/highcpu_Core.txt

bootflash:/vdc_2/highcpu_Dist.txt

     /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

From these three files we can diagnose what causes the CPU to jump up periodically.

Related Information

Average Rating: 5 (1 ratings)

Comments

nmicic Thu, 03/21/2013 - 06:36

Please correct this script. It has too agressive polling interval. Collection of the command will take longer then polling interval (up to 3-4 secondes), so this script may generate domino effect and run multiple EEM instances in background. More safe polling interval would be 10 secondes. Also, this EEM script always write to the same file which will grow after some time, so it may cause additional load when file is too big.

Actions

Login or Register to take actions

This Document

Posted May 27, 2011 at 5:53 AM
Stats:
Comments:1 Avg. Rating:5
Views:5615 Contributors:1
Shares:0

Related Content

Documents Leaderboard

Rank Username Points
1 177
2 64
3 60
4 50
5 23
Rank Username Points
5
0