cd /usr/ports/net-mgmt/mrtg/ make install clean
cat > /usr/local/etc/mrtg/load.pl
#!/usr/bin/perl $column = defined($ARGV[0]) ? $ARGV[0]:1; $hborder = defined($ARGV[1]) ? $ARGV[1]:100; $uptime=$1 if ($record=`/usr/bin/uptime`)=~m[up\s+(.*?,.*?),]; @loads=($1*100,$2*100,$3*100) if $record=~m[load averages: ([0-9.]+),\s+([0-9.]+),\s+([0-9.]+)]; print "$loads[$column]\n$loads[$column]\n$uptime\n".`hostname`."\n";
cat > /usr/local/etc/mrtg/mrtg.cfg
WorkDir: /usr/local/apache/htdocs/mrtg/ Target[cpu]: `/usr/local/etc/mrtg/load.pl 0 0` Options[cpu]: gauge, growright, nopercent MaxBytes[cpu]: 10000 WithPeak[cpu]: ymwd Title[cpu]: Analysis of CPU load averages PageTop[cpu]: CPU Load Averages ShortLegend[cpu]: % YLegend[cpu]: % of Load Legend1[cpu]: . Legend2[cpu]: % of Load Legend3[cpu]: . Legend4[cpu]: Peak % of Load LegendI[cpu]: Maximum: LegendO[cpu]: Loaded:
mkdir /usr/local/apache/htdocs/mrtg/ chmod +x /usr/local/etc/mrtg/load.pl echo "*/5 * * * * root /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg" >> /etc/crontab