loadavg : lightweight load, memory & transfer monitoring
Current version: 1.2 released 24 September 2008


loadavg main display
(larger version)

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.

While designed for use on a Linux Virtuozzo or OpenVZ VPS (Virtual Private Server), loadavg also works fine on a dedicated server.

Please note that on Virtuozzo v. 3 and OpenVZ servers the small beanc helper app is required to access VPS status information. The helper app is not required for Virtuozzo v. 2.6 servers.

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;
  • PHP: loadavg was initially developed with v. 4.3.10 and should run fine with later releases;
  • The beanc helper app if running on a Virtuozzo v. 3 or OpenVZ server;
  • PHP safe mode off. Safe mode disables the ability to run programs outside the script directory (reference).

Installation & Configuration
Important! If you have a Virtuozzo v. 3 or OpenVZ VPS you must install the beanc helper app before installing loadavg.

Installation may be done from a shell command line or via FTP. Installation should be done as an ORDINARY USER, not root. All loadavg directories & files should be owned by the user who owns the account/filespace where the scripts are installed.

Command line install:

1. Fetch & extract the files to public webspace:


[user@server] # cd public_html
[user@server] # wget http://www.silversoft.com/download/loadavg.tar.gz
[user@server] # tar -zxf loadavg.tar.gz

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

2. Next you edit the file "config.php" and set the correct path for the variable "$datadir". Your path will probably look something like this:

$datadir = '/home/USER/public_html/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';

3. Next you 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 * * * * /PATH/TO/php -q /PATH/TO/logger.php >/dev/null 2>&1

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

4. Wait. 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.

FTP install:

  1. Download the archive to your workstation and extract it to a temporary location.
  2. Edit the config.php file as above in #2.
  3. Upload all files to public webspace, ensuring that you preserve the directory structure.
  4. Set the cronjob in your control panel. See the example in #3 above.

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 :)

Upgrading from Previous Version
Current users of loadavg may upgrade like this:

  1. Fetch and extract the tarball to a temporary location on the server.
  2. Edit config.php to set your current full path to the loadavg logs directory.
  3. Copy *.php and display.css to your current loadavg installation directory, overwriting existing files.

Your existing log files will be preserved and used.

Download
Get loadavg here: loadavg.tar.gz.

Acknowledgements
Big thanks to David Eshelman for his contributions to loadavg -- including code improvements and user support.
And thanks to 'orange' for troubleshooting & fixing the '/proc/net/dev byte counter reset' issue.

Terms & Conditions

  • This script is an original work and is copyright Silversoft Solutions;
  • This script is provided to you for use free of charge;
  • You are permitted to modify the script for your own use;
  • You may redistribute the script in its original form, provided you do so without charge;
  • You may not modify the script and publicly redistribute it.

Liability:

  • The author assumes no liability for damage or loss that might be associated with the use of this script.

Bug Reports & Feedback
Bug reports and general comments are always welcome. Please address them to support@silversoft.com.

Customization

Silversoft's custom development services include customizing our tools and adding new features and technologies to meet your needs.
Integration

Silversoft can integrate & install our platform and products within your technology infrastructure so that you don’t have to tie up precious development resources.
Support

Our products come with a full range of support services from email based support to direct access to Silversoft's professional developers.
Free Downloads!

Silversoft is proud to be a sponsor of leading open source projects! Grab the latest versions of Cineplay, Cinecode and NCode all for free on our downloads page today!
Copyright Silversoft Solutions 2008