In this article we'll discuss more advanced methods for checking on your server's load averages to help determine at what times your server's usage might be spiking.

If you've read our previous article on server load monitoring, you should have a good understanding of what a load average represents and how you can see the live load average of your VPS (Virtual Private Server) or dedicated server using WHM (Web Host Manager).

For the examples below you'll need to login to your VPS or dedicated server via SSH (Secure Shell). You can read our guide on how to login to your server via SSH in order to figure out how to get logged in this way so that you can follow along.

Once you have your SSH client pulled up and successfully connected to your server, you should be presented with a prompt similar to:

-bash-3.2$

At this prompt you should be able to type in simple commands to get back specific information from the server. Here are a few commands you might use when looking at your server's usage:


uptime - Provides simple output showing how long the server has been up for, how many users are logged in, and the current load average.
uptime



top - Provides up to the minute information on currently running processes, also shows task states such as (running, sleeping, stopped, and zombie), shows memory usage as well as load averages.
top



sar - Provides information from the System Activity Reporting logs, such as historical load averages or disk I/O wait over a 30 day period.
sar



If you'd like to see the historic load average on your server, you can utilize sar -q. The -q flag is used to pull the load averages from your sar logs.

These more advanced commands can be used programmatically to build up more robust tools for you.

Below is an example that will go through all available load average reports and display anytime your load average would have been over a 1.00:

sar
 

for log in `ls -1 /var/log/sa/sa[0-9]* | sed 's#@##'`; do echo $log; sar -q -f $log | egrep -v "Average|ldavg|Linux" | awk '{if ($5>=1) print $1,$2,$5}'; echo ""; done | less

Code breakdown:

for log in `ls -1 /var/log/sa/sa[0-9]*'; This sets up a for loop with a variable called log, the value stored in this variable is going to be the current sar log that we're looping through.
do echo $log; This prints out the current sar log in our loop so we know any load averages that display under it will belong to that particular day.
sar -q -f $log | egrep -v "Average|ldavg|Linux" This will run the sar command with the -q flag to show load averages, and the -f flag to load activity from a file. Then our $log variable is put in place so that it loads up the current date in our loop. Finally the egrep -v "Average|ldavg|Linux" commands strips aways any lines that contain those words, so all we're getting back are actual numerical load averages.
awk '{if ($5>=1) print $1,$2,$5}'; This uses the awk command which is used for controlling columnated data, we tell the server that we only want to print out columns $1,$2, and $5 but only when column $5 is greater than 1.
echo ""; done | less This last part will simply print out a blank line after each loop to make it easier to read, and then issues our done command letting the server know we are done with the for loop that we started. Finally we "pipe" all of that information with the | character to the less command. This lets us easily page up and down through our results in the event that they took up more than one screen, and then you can just hit q to quit out of the date review mode once you're done looking at it all.
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

News / Announcements

WordPress wp-login.php brute force attack
Updated 2014-07-17 06:43 pm EST
Hits: 200949

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!