[mrtg] CPU monitoring

Daniel Curry dcurry at dollar.com
Fri Nov 19 15:11:02 MET 1999

Thanks to everyone that helped me get the Disk monitoring working.  My
management is VERY pleased with the kind of quality support available
for Open Source software.

But, I am still having problems with the cpuinfo.pl script.

Here is a manual run:

[dcurry at neon run]$ ./cpuinfo.pl 
up 43 days, 12:26, 49 users,
[dcurry at neon run]$ 

Here is the excerpt from mrtg.cfg file:

Target[viper.cpu]: `/home/dcurry/mrtg-2.8.9/run/cpuinfo.pl`
MaxBytes[viper.cpu]: 100
Options[viper.cpu]: nopercent
Unscaled[viper.cpu]: dwym
YLegend[viper.cpu]: % of CPU used
ShortLegend[viper.cpu]: %
LegendO[viper.cpu]:  CPU System:
LegendI[viper.cpu]:  CPU User:
Title[viper.cpu]: Machine name
PageTop[viper.cpu]: <H1>CPU usage for Machine name
   <TR><TD>System:</TD><TD>Machine name</TD></TR>

Here is the actual script ( just the portion I modified to support
digital unix 4.0d):

sub digital
   # Run commands
   $getcpu = `rsh $machine "sar -u 1 10 | grep Average"`;
   $getuptime = `rsh $machine "uptime"`;

   # Parse though getcpu and get data
   $getcpu =~ s/^[ \t]+\n$//;
#   print $getcpu;
   @gotcpu = split(/      /, $getcpu);
   @gotcpu[1] =~ s/^[ \t]+//;
   $getcpuusr = @gotcpu[1];
   $getcpusys = @gotcpu[4];

   # Print getcpu data for mrtg
   print $getcpuusr."\n";
   print $getcpusys;

   # Parse though getuptime and get data
   $getuptime =~ /^\s+(\d{1,2}:\d{2}..)\s+up\s+(\d+)\s+(\w+),/;
   $getuptime =~ s/^[ \t]+//;
   @gotuptime = split(/  /, $getuptime);

   # Print getuptime data for mrtg
   print @gotuptime[1]." ". at gotuptime[2]."\n";

   # Print machine name for mrtg
   print $machine."\n";


* To unsubscribe from the mrtg mailing list, send a message with the
  subject: unsubscribe to mrtg-request at list.ee.ethz.ch
* The mailing list archive is at http://www.ee.ethz.ch/~slist/mrtg

More information about the mrtg mailing list