KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

CPU Usage on RH8 false

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
scr



Joined: 17 Mar 2004
Posts: 7

PostPosted: Wed Mar 17, 2004 5:57 am    Post subject: CPU Usage on RH8 false Reply with quote

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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12806
Location: USA

PostPosted: Wed Mar 17, 2004 4:20 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
scr



Joined: 17 Mar 2004
Posts: 7

PostPosted: Thu Mar 18, 2004 1:54 am    Post subject: Reply with quote

[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
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12806
Location: USA

PostPosted: Thu Mar 18, 2004 12:46 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index