sar

We have a script that uses

sar -u 1 10 | awk '/Average/ { print ( $2 + $3 ) }'

to get the CPU usage of a mutli engine machine. We think we are getting wrong information from the above string. We think it is adding up the total of the 12 engines and reporting back the total not the overall average. Can anyone add their two cents as to what might be wrong?

They are percentages. Do they add up to 100? Or do they add up to 1200?

Seems to work on a multiple CPU SUN server although you are adding only user and system cpu usage leaving cpu time for wio.

I ran top at the same time just to see if it looked okay (and it did).

Post why you think it's wrong (and OS and version).

It is running on an Risc 6000 AIX 4.3.3 and the 12 totals add up to 100 and not 1200. I know this because I have monitoring tools that clearly show the totals being at 100 not 1200

Then it is working correctly if it's adding up to 100%. It is reporting on all 12 cpus. It isn't going to report each by itself (just as it doesn't tell you memory board one was used 90% but memory board 2 was used only 50%). And yes, it can specify disks because you can do something with them.

If you have a cpu problem, you add cpus (or move something off or run at different time).
Same with memory.

With disk you can move data around to get better performance - no need to buy new every time.

Sar should report on all cpu's since you want to know how the system as a whole is spending it's time.

Every "sar -u" that I've seen simply averages the per cpu stats and thus the output sums to 100 (give or take for rounding errors). This may not constitute "working correctly" but it certainly is "working as intended".

HP has added -M option to sar which gets per-cpu stats. With Sun, the latest OS's have a "mpstat" that can show per-cpu stats. But with just "sar -u" all you get is the average for whole system.