LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-06-2009, 08:12 AM   #1
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Rep: Reputation: 40
Very high system level processing


Hello all.


One of my virtual RHEL 5.1 boxes is running slow, and I've found that system-level processing is very high:
Code:
[root@server ]# sar -u 2 50 
02:17:57 PM       CPU     %user     %nice   %system   %iowait    %steal     %idle 
02:17:59 PM       all     55.72      0.00     44.28      0.00      0.00      0.00 
02:18:01 PM       all     62.00      0.00     38.00      0.00      0.00      0.00 
02:18:03 PM       all     64.71      0.00     35.29      0.00      0.00      0.00 
02:18:05 PM       all     63.82      0.00     36.18      0.00      0.00      0.00
I'm not very experienced on these things, but I belive that such a high persentage of system level CPU usage is higher than normal. Can anyone confirm this? And does anyone know how to figure out exactly why the kernel is using so much CPU?

Regards,
kenneho
 
Old 01-06-2009, 09:41 AM   #2
uks
Member
 
Registered: Jul 2007
Posts: 72

Rep: Reputation: 16
Have you checked the sar logs(usually at /var/log/sa/) and see if that helps ?
You have the memory usage, swapping details etc in these files which will tell you if this high cpu usage is related to that.
And if it is then you drive your investigations on those lines.
Other than that, if its happening all the while, you need to check the normal things, like top and see if you can find the process thats saturating the cpu
And to answer your question, Yes, this is high usage of the cpu(though I do not know the configuration details.)
 
Old 01-07-2009, 04:00 AM   #3
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Original Poster
Rep: Reputation: 40
Thanks for you reply.

The files found under /var/log/sa are very useful, as it displays a lot of information about the system. But do you know if there are any addons or something I can use to easier extrac relevant information for the files? As of now it's just a big text file, and I'm not quite sure what I'm looking for.
 
Old 01-07-2009, 04:24 AM   #4
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
Why dont you try to use "top" or "htop" to see what is doing the high system load. I think is a bit more easier.
 
Old 01-07-2009, 10:19 AM   #5
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by robertjinx View Post
Why dont you try to use "top" or "htop" to see what is doing the high system load. I think is a bit more easier.
I do use "top", but since this problem seem to come and go I'm often forced to search the historical data collected by for example sar.
I'm quite puzzled, since I don't (yet, at least) see any reason why the kernel (i.e. system-level) is using so much CPU power.
 
Old 01-07-2009, 10:29 AM   #6
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
Try this small script, copy it and save it under the name "cpuload" for example and then add it to crontab like this:

*/10 * * * * ( su - root -c '/path/to/cpuload' ) >/dev/null 2>&1

PHP Code:
#!/bin/sh -e

AWK=/usr/bin/awk
SAR
=/usr/bin/sar
GREP
=/bin/grep
TR
=/usr/bin/tr
HEAD
=/usr/bin/head
PS
=/bin/ps
SORT
=/usr/bin/sort
HOSTNAME
=$(hostname -f)
SED=/bin/sed
LOAD
=49
CAT
=/bin/cat
MAILFILE
=/tmp/mailviews$$
MAILER=/usr/bin/mail
mailto
="somemail@example.org"

for path in $PATH;
        do
        
CPU_LOAD=$($SAR -P ALL 1 2 $GREP 'Average.*all' $AWK -F" " '{ print 100.0 -$NF}'|awk '{$1=sprintf("%.0f",$1)}1')
    
#CPU=$(echo $CPU_LOAD|awk '{$1=sprintf("%.0f",$1)}1')
    
echo $CPU_LOAD
 
if [ $CPU_LOAD -gt $LOAD ]; then
                PROC
="$($PS -eo user,pcpu,pid -o comm= --no-heading| $SORT -k2 -n -r|head -4)"
                
echo -"$PROC\n"
                
echo "Please check your processes on ${HOSTNAME} the value of cpu load is $CPU_LOAD$MAILFILE
        
echo "" >> $MAILFILE
        
echo -"USER\tCPU\tPID\tPROC" >> $MAILFILE
        
echo -"$PROC\n" >> $MAILFILE
                $CAT $MAILFILE 
$MAILER -"CPU Load is $CPU_LOAD % on ${HOSTNAME}$mailto
        rm 
-f $MAILFILE
 fi

done

exit 
Im using this on my servers and seems to work quite fine. Just try it and see in the mail whats making the high load.
 
Old 01-07-2009, 10:40 AM   #7
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
I forgot to add there, that you might need to change some of the variables as some of the apps are in different location. Like "awk" or "mail" and so on. So good luck!

P.S. it doesn't work if the variables are not correct, also you can adjust the value of LOAD to lets say 55 or something similar.
 
Old 01-07-2009, 11:47 AM   #8
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by robertjinx View Post
Try this small script, copy it and save it under the name "cpuload" for example and then add it to crontab like this:

*/10 * * * * ( su - root -c '/path/to/cpuload' ) >/dev/null 2>&1

Im using this on my servers and seems to work quite fine. Just try it and see in the mail whats making the high load.
Another neat trick is to use 'which' to set the locations after setting appropriate paths /bin:/sbin:/usr/bin:/usr/sbin etc... PROG=`which name` which makes things a bit more portable, although if you're using awk and sed and such you need to be careful that the output is the same, sometimes there are discrepancies.
 
Old 01-08-2009, 01:39 AM   #9
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Original Poster
Rep: Reputation: 40
Thanks for the script - I'll give it a try and report back here.
 
Old 01-12-2009, 04:55 AM   #10
uks
Member
 
Registered: Jul 2007
Posts: 72

Rep: Reputation: 16
Yes the log files are too huge but I forgot to mention that there are ways to query them.
Let me give you an example:
sar -f /var/log/sa/sa08 -P ALL

will pull out just the CPU activity info from the accounting file for the 8th.
And if you combine this with the time interval like this:

sar -f /var/log/sa/sa08 -P ALL -s 15:00:00 -e 16:00:00

you can get it between the specified time frame, here between 3 and 4 pm.

Check sar -help and you can try the various combinations there.

--Ukesh Upendran
 
Old 01-12-2009, 05:20 AM   #11
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Original Poster
Rep: Reputation: 40
Great, this was most helpful. Such features are not always easy to discover by oneself.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help for high level shell script kushkothari Programming 13 10-29-2008 11:16 PM
LXer: MochiKit feels like Python but delivers high-level JavaScript LXer Syndicated Linux News 0 11-29-2006 08:21 AM
High-level question about printing via a router? gtjmn308 Linux - Networking 2 09-23-2006 09:21 AM
What's the best distribution for high processing on a laptop? maelstrom209 Linux - Laptop and Netbook 11 10-07-2004 06:06 AM
is parallel processing possible in distrributed system? sabeen Linux - Distributions 1 03-26-2004 06:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration