Project

General

Profile

« Previous | Next » 

Revision 1b114acb

Added by Hamish Coleman over 14 years ago

  • ID 1b114acb828d9e66b3f60a24726cc66cb00e7b58

Add a quick implementation of a munin datasource

View differences:

mrtg.cgi
'/usr/share/WWW/mrtg/mrtg.cfg',
);
my @munin_datafiles = (
'/var/lib/munin/datafile',
);
# FIXME - globals
my $gifdone = 0; # Scan for newest graph and save info for later
my $warnings;
......
}
}
sub config_load_munin(@) {
while (@_) {
my $filename = shift;
my $fh = new FileHandle $filename,"r";
if (!defined $fh) {
# FIXME globals
$warnings .= "Warning: Could not open $filename $!\n";
return;
}
my $d={};
while(<$fh>){
if ( m/^version/) {
next;
}
if ( m/^(.*).graph_title (.*)/) {
# store until we have a category
$d->{$1}=$2;
}
my $title;
if ( m/^(.*).graph_category (.*)/) {
$title = $d->{$1};
}
if ( m/^([^;]+);([^:]+):(([^.]+)\.?([^.]+)?).graph_category (.*)/) {
#print "group=$1\n";
#print "host=$2\n";
#print "test=$6\n";
#print "instance=$3\n";
#print "title=$title\n";
my $category=lc $6;
my $target;
$target = "$1,$2,$category,$3";
config_save_val($filename,$target,'_grapher','munin');
config_save_val($filename,$target,'xsize',497-100);
config_save_val($filename,$target,'ysize',undef);
config_save_val($filename,$target,'title',$title);
my $path_local='/var/cache/munin/www/';
my $path_www='/munin/';
my $path_this="$1/$2/$4";
if (defined $5) {
$path_this.="/$5";
}
config_save_val($filename,$target,'_imagefile',$path_local.$path_this);
config_save_val($filename,$target,'_url',$path_www.$path_this);
}
}
}
}
# Itterate through the loaded targets and read their mtime and
# any other filesystem details for them.
#
......
"\n";
config_load_file(@config_files);
config_load_munin(@munin_datafiles);
config_read_filesystem();
maketree();

Also available in: Unified diff