AIX

AIX check cpu usage

Description:

using vmstat to check idle percentage

Current Version

Last Release Date

June 15, 2009

Compatible With


Project Files
Project Notes
$ ./check_aix_cpu.pl usage: ./check_aix_cpu.pl -w # -c # options: -w warning threshold (%) -c critical threshold (%) $ ./check_aix_cpu.pl -w 90 -c 95 OK - CPU usage at 77% UPDATED old: vmstat 2 4 new: vmstat 1 4 To speed things up.
Reviews (2) Add a Review
Adjusting for AIX 6.1
by gd, May 31, 2016
This is a useful check. FWIW... At a customer site where they use this check for AIX 6.1, and noticed an issue when the vmstat samples look similar to the following:

10 0 2750794 5040508 0 0 0 0 0 0 75 7806 2920 6 1 93 0 0.34 11.4
8 0 2750684 5040617 0 0 0 0 0 0 345 5356 2780 0 1 99 0 0.08 2.6
8 0 2750686 5040615 0 0 0 0 0 0 53 4138 2640 0 0 99 0 0.04 1.3
11 0 2750686 5040615 0 0 0 0 0 0 8 4358 2965 0 0 99 0 0.04 1.3

Note that the first field in the second and third sample above have a leading whitespace character in "r" column.

That appears to throw off the field identification and calculation.

You can see the wild inconsistencies, if you loop the check from command line:

OK - CPU usage at 75.25%
CRITICAL - CPU usage at 100%
CRITICAL - CPU usage at 100%
OK - CPU usage at 50.5%
CRITICAL - CPU usage at 100%
CRITICAL - CPU usage at 100%
OK - CPU usage at 50.5%
OK - CPU usage at 1%
OK - CPU usage at 50.75%
CRITICAL - CPU usage at 100%

And then compare that to a simple "vmstat 1":

4 0 2691885 5098619 0 0 0 0 0 0 30 3364 2164 0 0 99 0 0.03 1.0
6 0 2691885 5098619 0 0 0 0 0 0 29 3595 2239 1 0 99 0 0.05 1.6
0 0 2693761 5096742 0 0 0 0 0 0 126 9301 2525 17 1 82 0 0.84 28.1
85 0 2693762 5096741 0 0 0 0 0 0 51 3564 2223 0 0 99 0 0.04 1.5
35 0 2693762 5096741 0 0 0 0 0 0 19 3509 2129 0 0 99 0 0.04 1.2
32 0 2693762 5096741 0 0 0 0 0 0 8 3251 2152 0 0 99 0 0.03 0.8
31 0 2693697 5096806 0 0 0 0 0 0 20 3765 2153 1 0 98 0 0.09 3.0
0 0 2693918 5096584 0 0 0 0 0 0 151 6348 2315 5 1 94 0 0.29 9.8

Note that the CPU is typically > 90+% idle...

To test a fix to this, I used "xargs -l" to sanitize the vmstat output, accounted to the actual number of fields, and then adjusted the "strip" portion for whitespace:

# diff orig_check_aix_cpu.pl new_check_aix_cpu.pl

30c30
open(PS, "/usr/bin/vmstat 1 4 | egrep -v '[a-z,A-Z]|-' |egrep '[0-9]' | xargs -l |") || return 1;

32c32
(undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$idle,undef,undef,undef) = split(/[s+n]+/);

When I run the modified script in a loop, the results looks a bit more sane:

OK - CPU usage at 1%
OK - CPU usage at 1%
OK - CPU usage at 1.75%
OK - CPU usage at 1%
OK - CPU usage at 4%
OK - CPU usage at 1%
OK - CPU usage at 2%
OK - CPU usage at 1%

YMMV...
Helpful? Yes  No 
Showing 100% everytime...
by bkfitz, December 31, 2012
bla@bla:~/temp$ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
1 0 0 1163264 73420 1191884 0 0 59 23 270 450 4 2 94 0
bla@bla:~/temp$ ./check_aix_cpu.pl -w 20 -c 40
CRITICAL - CPU usage at 100%
Helpful? Yes  No 
Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
3.8 (4)
Favorites
0
Views
119,142