I don't have a CPU graph, but I do have graphs for network traffic, I/O token rate, I/O tokens available, and 5- and 15-minute system load average.
Caveat: I've noticed that reboots produce screwy results with my network traffic graph, which don't jibe with the graphs on the LPM.
This example will drop
traffic.html,
tokens.html,
io_rate.html, and
load_avg.html files in the WorkDir.
A cron job should run mrtg every five minutes. It will need to run at least three times before you start getting meaningful results.
/etc/mrtg.cfg:
Code:
# This file is for use with mrtg-2.5.4c
# Global configuration
WorkDir: /var/www/some/where
WriteExpires: Yes
Target[traffic]: `/usr/local/bin/traffic.pl`
Title[traffic]: Traffic Analysis for Linode VPS
PageTop[traffic]: <H1>Bandwidth Usage</H1>
Options[traffic]: logscale
MaxBytes[traffic]: 12500000
Title[tokens]: I/O Tokens for Linode VPS
Target[tokens]: `/usr/local/bin/tokens.pl`
PageTop[tokens]: <H1>I/O Tokens</H1>
Options[tokens]: gauge
MaxBytes[tokens]: 400000
YLegend[tokens]: Tokens
ShortLegend[tokens]: Tokens
LegendI[tokens]: Tokens:
LegendO[tokens]:
Legend1[tokens]: I/O Tokens Available
Legend2[tokens]:
Title[io_rate]: I/O Rate for Linode VPS
Target[io_rate]: `/usr/local/bin/tokenrate.pl`
PageTop[io_rate]: <H1>I/O Token Usage Rate</H1>
Options[io_rate]: logscale
MaxBytes[io_rate]: 400000
YLegend[io_rate]: Tokens/sec
ShortLegend[io_rate]: Tokens/sec
LegendI[io_rate]: Tokens/sec:
LegendO[io_rate]:
Legend1[io_rate]: I/O Token Usage Rate
Legend2[io_rate]:
Target[load_avg]: `/usr/local/bin/uptime.pl`
Title[load_avg]: Load Averages and Uptime
Options[load_avg]: gauge,logscale
PageTop[load_avg]: <H1>System Load Averages</H1>
YLegend[load_avg]: Load Average
The uptime.pl script:
Code:
#!/usr/bin/perl
# Retrieve 5-minute and 15-minute load averages for system
# for use by MRTG
$text = `uptime`;
($uptime,$avg5min,$avg15min) = ($text =~ m/^.*up (.*), \d+ user.*, load average: \S+, (\S+), (\S+)$/o);
$host = `hostname`;
# use printf here to round the averages
printf("%.1f\n%.1f\n%s\n$host\n", $avg5min, $avg15min, $uptime);
The tokens.pl script:
Code:
#!/usr/bin/perl
$line = `/usr/bin/uptime`;
($uptime) = ($line =~ m/^.*up (.*),\s+\d+\s+users*,\s+load average:.*$/o);
$host = `/bin/hostname`;
open IOSTATUS, "/proc/io_status";
$line = <IOSTATUS>;
close IOSTATUS;
($tokens) = ($line =~ m/^.* io_tokens=(\d+) .*$/o);
print "$tokens\n0\n$uptime\n$host\n";
The tokenrate.pl script:
Code:
#!/usr/bin/perl
$line = `/usr/bin/uptime`;
($uptime) = ($line =~ m/^.*up (.*),\s+\d+\s+users*,\s+load average:.*$/o);
$host = `/bin/hostname`;
open IOSTATUS, "/proc/io_status";
$line = <IOSTATUS>;
close IOSTATUS;
($count) = ($line =~ m/^io_count=(\d+) .*$/o);
print "$count\n0\n$uptime\n$host\n";
The traffic.pl script:
Code:
#!/usr/bin/perl
$line = `/usr/bin/uptime`;
($uptime) = ($line =~ m/^.*up (.*),\s+\d+\s+users*,\s+load average:.*$/o);
open IFCONFIG, "/sbin/ifconfig eth0|";
while(<IFCONFIG>) {
($in, $out) = (m/^.*RX bytes:(\d+).*TX bytes:(\d+).*$/o);
last if($in);
}
close IFCONFIG;
$host = `/bin/hostname`;
print "$in\n$out\n$uptime\n$host\n";
HTH...