This standalone perl script by Justin Davidson generates a whole cfg file with CPU graphs.
Code:
#!/usr/bin/perl
if ($ARGV[0] eq '') {
print "Usage: cfgcpumaker <snmpread>@<host>\n";
exit;
}
my $snmpver = "2c";
my ($snmpread, $host) = split(/@/, "@ARGV");
my @indexs = ();
@hrDeviceTypes = `snmpwalk -On -v $snmpver -c $snmpread $host hrProcessorLoad`;
foreach $t (@hrDeviceTypes) {
chomp($t);
(@sections)=split(/\s/,"$t");
(@vals)=split(/\./, "$sections[0]");
push(@indexes, "$vals[12]");
}
print "WorkDir: /home/mrtg/data/boxstats\n";
print "Directory[_]: $host\n";
print "PageTop[_]: $host\n";
print "Options[_]: gauge,growright,nopercent\n";
print "Forks: 10\n";
print "Refresh: 300\n";
print "LoadMIBs: /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt\n";
print "#\n";
print "# CPU Monitoring\n";
print "# (Scaled so that the sum of all three values doesn't exceed 100)\n";
print "#\n";
my $count = 0;
foreach $i (@indexes) {
$count++;
print "Target[$host.cpu.$count]:hrProcessorLoad.$i&hrProcessorLoad.$i:$snmpread\@$host\n";
print "Title[$host.cpu.$count]: Server CPU Load\n";
print "PageTop[$host.cpu.$count]: <H1>CPU Load #$count</H1>\n";
print "MaxBytes[$host.cpu.$count]: 100\n";
print "ShortLegend[$host.cpu.$count]: %\n";
print "YLegend[$host.cpu.$count]: CPU Utilization\n";
print "Legend1[$host.cpu.$count]: Current CPU percentage load\n";
print "LegendI[$host.cpu.$count]: Used\n";
print "LegendO[$host.cpu.$count]:\n";
print "Unscaled[$host.cpu.$count]: ymwd\n";
print "\n\n";
}
exit 0;