Building network automation solutions

9 module online course

Start now!

Display top CPU processes on the router

I've almost started writing a Tcl procedure to display top-10 CPU-intensive processes on a router ... and then discovered the sorted option of the show processes cpu command. Even more, starting in IOS release 12.2T, the show processes cpu history command gives you a nice CPU utilization graph. Sample printouts are included below:
router#show processes cpu sorted 1min
CPU utilization for five seconds: 1%/0%; one minute: 2%; five minutes: 2%
PID Runtime(ms) Invoked uSecs 5Sec 1Min 5Min TTY Process
5 180080 9762 18447 0.00% 1.75% 1.73% 0 Check heaps
62 648 181 3580 0.00% 0.31% 0.12% 2 Virtual Exec
25 4116 173 23791 0.49% 0.05% 0.00% 0 Per-minute Jobs
30 848 1172 723 0.00% 0.01% 0.00% 0 IP Input
81 12 357 33 0.08% 0.00% 0.00% 0 CEF Scanner
6 8 2 4000 0.00% 0.00% 0.00% 0 Pool Manager
4 0 86 0 0.00% 0.00% 0.00% 0 DHCPD Timer
3 4 27 148 0.00% 0.00% 0.00% 0 CRYPTO IKMP IPC
9 0 1 0 0.00% 0.00% 0.00% 0 AAA high-capacit
10 52 238 218 0.00% 0.00% 0.00% 0 ARP Input
... rest deleted ...
router#show processes cpu history
22222
22 11111 11111
100
90
80
70
60
50
40
30
20 *****
10 *****
0....5....1....1....2....2....3....3....4....4....5....5....
0 5 0 5 0 5 0 5 0 5
CPU% per second (last 60 seconds)

2121121112121112121 11111222222122 12211121119112121 12221
1926405121716641818 76211100148411 70088401221831611470011
100
90 *
80 *
70 *
60 *
50 *
40 *
30 * *
20 **** ** ***** **** ** ****** ** ***** * ** *** ****
10 ******************* **********#*** **********#****** *****
0....5....1....1....2....2....3....3....4....4....5....5....
0 5 0 5 0 5 0 5 0 5
CPU% per minute (last 60 minutes)
* = maximum CPU% # = average CPU%
1
80
60
100 *
90 **
80 **
70 **
60 **
50 **
40 **
30 **
20 **
10 **
0....5....1....1....2....2....3....3....4....4....5....5....
0 5 0 5 0 5 0 5 0 5
CPU% per hour (last 72 hours)
* = maximum CPU% # = average CPU%

4 comments:

  1. can u please explain little bit more about the #sh proc cpu history, output.
  2. Hi Ivan,

    I there a process/ script to check top 5 processes on CPU? When I run "sh process cpu sorted | e 0.00" i still get ~15 entries. I just want top 5 to be filtered from this output.

    I was thinking of piping this output in a text file and then parse first 5 lines from it.
    Is it possible to write a perl/tcl script to read first five lines of output and then display it?

    Any help will be greatly appreciated.

    Regards,
  3. This should be pretty easy to do with Tcl. Search my blog and wiki.nil.com.
  4. Hi Ivan,

    I noticed that my previous comment did not post. I got it working for me. Thanks a ton.

    Got the reference script from wiki.nil.com.
Add comment
Sidebar