Problem solved.
My mrtg-load.cfg:
CODE
Workdir: /usr/local/psa/home/vhosts/yourdomain/httpdocs/mrtg
Target[load]: `perl /etc/mrtg/mrtg-load.pl`
Title[load]: Processor stats at home
PageTop[load]: <H1>Processor stats</H1>
MaxBytes[load]: 500
Unscaled[load]: ymwd
Options[load]: growright, gauge, nopercent
YLegend[load]: System Load (%)
ShortLegend[load]: Load
Legend1[load]: System load during the last 1 min
Legend2[load]: System load during the last 5 min
LegendI[load]: 1 min
LegendO[load]: 5 min
Here's the perl script (mrtg-load.pl) that
mrtg-load.cfg calls:
CODE
!/usr/bin/perl
#
# Perl script to gather load average information for MRTG
# Copyright (C) 2000 Chris Gushue <seymour@lazygenes.net>
#
# Put something like this in your /etc/mrtg.cfg
#
# Title[load]: System Load for krypton.lazygenes.net
# PageTop[load]: <H1>486 DX4-100, 12MB RAM</H1><BR><H2>Debian 2.1 (slink) GNU/Linux</H2>
# Target[load]: `/usr/local/bin/load.pl`
# MaxBytes[load]: 100
# Options[load]: growright, gauge
# YLegend[load]: System Load (%)
# ShortLegend[load]: Load
# Legend1[load]: System load during the last 1 min
# Legend2[load]: System load during the last 5 min
# LegendI[load]: 1 min
# LegendO[load]: 5 min
# Edit this variable for your host
$hostname = "yourdomain.com";
# Open /proc/loadavg and load into @loadavg
open(LOADAVG, '/proc/loadavg') or die "Can't open /proc/loadavg? That's probably not goodn";
while(<LOADAVG>) {
@loadavg = split(/s/, $_);
}
close(LOADAVG);
# Get load averages, multiply each by 100 for MRTG
$load1 = $loadavg[0]*100;
$load2 = $loadavg[1]*100;
$load3 = $loadavg[2]*100;
# Get a nice uptime string
open(UPTIME, '/proc/uptime') or die "Can't open /proc/uptime? That's probably not goodn";
while(<UPTIME>) {
@uptime = split(/s/, $_);
}
close(UPTIME);
# This section based on Freddie's C source for mrtguptime
$days = int($uptime[0] / 86400);
$secs = int($uptime[0] % 86400);
$hours = int($secs / 3600);
$secs = int($secs % 3600);
$mins = int($secs / 60);
$secs = int($secs % 60);
if ($days >= 1) {
if ($hours >= 1) {
if ($mins >= 1) { $uptime = "$days days, $hours hours, $mins mins"; }
else { $uptime = "$days days, $hours hours"; }
}
else {
if ($mins >= 1) { $uptime = "$days days, $mins mins"; }
else { $uptime = "$days days"; }
}
}
else {
if ($hours >= 1) {
if ($mins >= 1) { $uptime = "$hours hours, $mins mins"; }
else { $uptime = "$hours hours"; }
}
else {
if ($mins >= 1) { $uptime = "$mins mins"; }
else { $uptime = "0 mins"; }
}
}
# Output stuff for MRTG
print "$load1n";
print "$load2n";
print "$uptimen";
print "$hostnamen";
exit 0;
...to access your stats visit
http://yourdomain.com/mrtg/load.html
my /etc/crontab entry looks like this:
0-59/5 * * * * root /usr/local/mrtg-2/bin/mrtg /etc/mrtg/mrtg-load.cfg
(I installed mrtg 2.9.17 from source tarball)