View previous topic :: View next topic |
Author |
Message |
scr
Joined: 17 Mar 2004 Posts: 7
|
Posted: Wed Mar 17, 2004 5:57 am Post subject: CPU Usage on RH8 false |
|
|
the script cpu.sh contains an error which cuases the shown CPU load to be more than 100%
false: Linux) vmstat -n 1 2 | tail -1 | awk '{print $(NF-3)+$(NF-2)}';;
right: Linux) vmstat -n 1 2 | tail -1 | awk '{print $(NF-1)+$(NF-2)}';;
HTH, Rainer |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12806 Location: USA
|
Posted: Wed Mar 17, 2004 4:20 pm Post subject: |
|
|
Are you sure?
Accourding to man pages:
vmstat -n 1 2 | tail -1 | awk '{print $(NF-3)+$(NF-2)}' will retrun user time (NF-3) + system time (NF-2)
vmstat -n 1 2 | tail -1 | awk '{print $(NF-1)+$(NF-2)}' will show idle (NF-1) + system time (NF-2)
Regards
Alex |
|
Back to top |
|
|
scr
Joined: 17 Mar 2004 Posts: 7
|
Posted: Thu Mar 18, 2004 1:54 am Post subject: |
|
|
[root@TUX root]# vmstat -V
procps version 2.0.7
[root@TUX root]# vmstat -n
procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id
0 0 0 0 34300 84804 282404 0 0 4 55 35 162 3 1 96
[root@TUX root]# vmstat -n 1 2 | tail -1 | awk '{print $(NF-3)+$(NF-2)}'
831
[root@TUX root]# vmstat -n 1 2 | tail -1 | awk '{print $(NF-1)+$(NF-2)}'
1
In prectice the one I sent you produces reliable and true results.
HTH, Rainer |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12806 Location: USA
|
Posted: Thu Mar 18, 2004 12:46 pm Post subject: |
|
|
Oh, I see. procps version 2.0 and version 3.1 have different output formats.
Script must check version and use different awk commands. Or we can have different scripts for differents platforms.
Thank you for information.
Regards
Alex |
|
Back to top |
|
|
|