cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4966
Views
0
Helpful
28
Replies

EEM Applet to Monitor CPU

francisco_1
Level 7
Level 7

I need to what the PID using CPU utilization at 50%.

All i see on the syslog server is " %HA_EM-2-LOG: highcpu: HIGH CPU"

EEM doesnt tell me what process is consuming the CPU at 50%

Any ideas?

event manager applet highcpu
event snmp oid 1.3.6.1.4.1.9.9.109.1.1.1.1.10.1 get-type exact entry-op ge entry-val 50 poll-interval 5
action 1.0 cli command "enable"
action 2.0 cli command "show proc cpu sorted"
action 3.0 syslog priority critical msg "HIGH CPU"

Francisco.

2 Accepted Solutions

Accepted Solutions

Right now it does.  That is, the script will not execute unless the OVERALL CPU usage is at or above 50%.  It will then email all processes which have a five second CPU utilization above 0%.  This way, you can get an idea of ALL CPU consumers that contributed to the 50% overall CPU utilization.  I thought this is what you would want.  However, if you want to only see processes at or above 50% on their own, I can do that, but I do not think the script will provide useful data at that point.

--

Please support CSC Helps Haiti

https://supportforums.cisco.com/docs/DOC-8895

https://supportforums.cisco.com

View solution in original post

Your version of IOS may require another parameter.  Try this version.

View solution in original post

28 Replies 28

Joe Clarke
Cisco Employee
Cisco Employee

You're running the command "show proc cpu sorted", but that output is not going anywhere.  You might consider sending the output out via email:

action 4.0 mail server 10.1.1.1 to user@company.com from router@company.com subject "Show Process Output" body $_cli_result

Joe,

The switches dont have access to the mail server. Without outputing the "show proc cpu sorted" via email, can i not syslog it?

Sure, you can, but that would a HUGE syslog message.  Some syslog servers have a 1024 byte maximum message size.  You could try something like "show proc cpu sorted | exc 0.00" to weed out some of the noise.

Joe,

I only need to run eem script for a short period time.

Should i expect to see the process PID consuming 50% of CPU on the syslog server with my eem script config?

All i see on the syslog server is the message " %HA_EM-2-LOG: highcpu: HIGH CPU". or there is a way to check event manager output on the switch to capture the process PID.

Thanks Joe

any one please.

Is the EEM the tool for what i am trying to do?

Any suggestion please.

Change action 3.0 to:

action 3.0 syslog priority critical msg "HIGH CPU: $_cli_result"

Joe,

That is very aggressive. it output to syslog all active processes even with 0.00% CPU utilization. All i want to capture is a process using 50% CPU.

Thanks

Francisco

That you can't do without Tcl or programmatic applets.  What version of IOS do you have?

12.2.18-SXF14 on C6500 and 12.2(24)T2.

Not possible to accomplish what i am trying to do with EEM?

Don't know much about tcl! Can you assist us?

Francisco

One facet of EEM is Tcl.  You are currently using an applet policy, but you could easily do what you want in Tcl.  The 12.4(24)T router would allow you to do what you want with an applet, but that wouldn't work on the 6500.  One Tcl policy could be made to do what you want on both.  I will post suhc a policy in a while.

Thank you Joe.

Here is a policy which will replace your existing applet policy.  Before you can register it, you must create a directory on flash to hold EEM Tcl policies.  For example, flash:/policies.  Then, copy the sn_alert_high_cpu.tcl script into this directory.  Then, you need to set three EEM environment variables in the running config.  For example, to maintain your current level of polling and threshold:

event manager environment high_cpu_cpu_id 1

event manager environment high_cpu_threshold 50

event manager environment high_cpu_poll_freq 5

Then configure:

event manager policy sn_alert_high_cpu.tcl


When the CPU crosses 50%, you should see a syslog which contains the top non-zero CPU consumers.

Joe,

Thanks for the script.

I think we are almost there.

Regarding the "event manager environment high_cpu_threshold 50", does the value 50 mean 50.00% or 0.50% of CPU?.

I am testing your tcl script in our lab before i use it in production. Since i am not generating lot of traffic on the switch i have changed the threshold to 8 instead. With a value of 8 i am seeing processes that's using 0.08% and above appearing on the syslog server (see below). if i change it to 50 i am see processes with 0.50% and above. That's good but i am interested in anything at 50.00% or above not 0.50%. Does that make sense?

Can we change the tcl file "High CPU threshold" to a number say between 0.00 and 100.00 to reflect 0.00% to 100.00%  ?

*Mar  1 01:14:02.379: %HA_EM-2-LOG: system:/lib/tcl/eem_scripts_registered/sn_alert_high_cpu.tcl: HIGH CPU: top processes: Compute load avg (0.25%) SSS Feature Time (0.08%) Virtual Exec (0.17%) Exec (0.08%) IGMP Input (0.34%) PIM Process (0.08%) EEM TCL Proc (25.74%) EEM ED SNMP (0.51%) Syslog (0.34%) RBSCP Background (0.08%) HC Counter Timer (0.08%) bsm_xmt_proc (0.17%) AAA SEND STOP EV (0.08%) EEM Server (0.76%) Mwheel Process (0.17%)

I configured the script to react when the overall CPU is high, then print out those top processes with non-zero CPU utilizations.  You may not be seeing one process at 50% when the overall CPU utilization is at 50.  I can certainly change the script, but I think the way it is working now is probably what you want.  Checking that an individual process' CPU utilization is at or above 50 may not yield anything.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: