Debian Admin - Your way to Debian World

October 2, 2006

lightweight load, memory and network monitoring Using loadavg

by @ 9:55 am. Filed under Monitoring

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

loadavg is a simple and lightweight method of monitoring load, memory usage and transfer throughput on a Linux server.Every method of monitoring has an impact on the system being monitored — loadavg is designed to keep that impact as low as possible. It generates HTML & CSS charts, thereby shifting much of the work from the server to the client — your web browser.

loadavg consists of two scripts

logger.php simply reads a few files in /proc and writes out a line of data to a log file. It takes very little CPU time
and memory.

index.php reads through that logfile and produces HTML output for each line. This HTML is then compressed and
transmitted to you. Again, that takes very little server CPU and memory.

Perhaps the most intensive part of the whole operation is the decompression and rendering of the HTML, which is done by
the web browser on your workstation.

Requirements

Linux Operating System

Apache webserver with php support

PHP safe mode off. Safe mode disables the ability to run programs outside the script directory

Installation and Configuration

First thing is you need to install apache webserver with php support you can check here for this

Now you need to download loadavg script in you webserver root directory i am using debian and this can be same for
ubuntu and other debian derivated distributions

My webserver root document path is /var/www/

/#cd /var/www/

/var/www# wget http://www.labradordata.ca/downloads/loadavg.tar.gz

/var/www#tar -zxf loadavg.tar.gz

When you extract the tarball, a “loadavg” directory will be created.

Next you edit the file “config.php” and set the correct path for the variable “$datadir”. Your path will probably look something like this and you need to change this.

$datadir = ‘/home/USER/public_html/loadavg/logs/’;

to

$datadir = ‘/var/www/loadavg/logs/’;

Adjust the path as necessary. Make sure there is a trailing slash. Other settings in config.php may be changed according to personal preference.

Also set the correct value for “$eth”, your ethernet interface. The default value is “venet0″ for a VPS. Change it to “eth0″ for a dedicated machine (or whichever interface you use):

$eth = ‘venet0′;

to

$eth = ‘eth0′;

Next you need to set the cronjob. The script “logger.php” must be set to run exactly every 6 minutes. Do NOT attempt to change the timing, it simply will not work correctly.

Use “crontab -e” to edit the crontab and insert a line something like this:

*/6 * * * * /usr/bin/php -q /var/www/loadavg/logger.php >/dev/null 2>&1

Edit the paths to php and logger.php as necessary.

The logger.php must run 3 times before there is enough data to start producing charts. In 20 minutes or so, check the
index.php page in your web browser.

http://yourserverip/loadavg/index.php

You should see the following screen

Optional Settings

There are a number of settings in config.php which may be tailored to your personal preference. See the comments in
that file.

In particular you may want to adjust the $txchart and $rxchart values. These determine the y-axis (vertical) scale of
the transmit & receive charts. For example, if you regular do 30 KB/sec transmit, set $txchart to a value slightly higher, perhaps 50 KB/sec.

Note on First Day Results:

The loadavg graphs will not display quite right during your first day. Once the second day is started the graphs will be correct. This is a design issue that may (or may not) eventually be fixed.

If you want to know about this script check here for more details

Tags: , , , ,
 

You may also be interested in...

2 Responses to “lightweight load, memory and network monitoring Using loadavg”

  1. Pseudo-Anonymous Coward Says:

    FYI, make sure you have the PHP binary installed (i.e. php5-cli) not just the apache mod. The scripts need to be executed outside of apache and the php binary allows that to happen.

  2. Slawa Says:

    There is another script working according to the same idea, but data is shown in real-time, for free and with zero installation and configuration. Just copy the script into the web-server and enjoy:
    http://phploadavg.sourceforge.net/

Leave a Reply

Subscribe RSS Feed

subscribe to the Debian Admin RSS feed

Internal links:

Sponsors:



Categories:

Support Debian Admin

Amount $:
Website(Optional):

Sponsors:

Archives:

Related Links:


Favourite Sites:

Wordpress Collection
Windows Reference
Ubuntu Geek
DebianHelp
All About Debian Tutorials
Power Electrical
Check Your IP Here
Debian,Ubuntu News
DebCentral
Tuxmachines
Capnkirby
Libervis
Nuxifield
Linux Horizon
Linux Appfinder
Debuntu
GNU/Linux For Everyone
Free Penguin
DebianAdmin is not related to the Debian Project.
This site is copyright © 2006,2007 Debian Admin
All Trademarks are the property of their respective owners.
The contents of this website may not be mirrored or archived without the express written permission of DebianAdmin Site Owner.

DISCLAIMER: All the information, troubleshooting methods, utilities offered in this website is provided AS-IS, without any warranties. Though I strive for perfection, and always test the validity and effectiveness of the troubleshooting content in various systems, I assume no responsibility for your use of these Fixes, Utilities and other troubleshooting advice. The author will not be liable for any special, incidental, consequential or indirect damages due to loss of data or any other reason. All use is completely at your own risk. Changes to the existing content and new additions are made to this website periodically, without notification.
Rodney's Kontera DynamiContext Plugin plugged in.