A quick hack to allow collectdčhtml.pl to work with newer collectd. It isn't 
best (function duplicates), but it works.

--- collectd_orig.pl	2009-02-20 14:19:20.000000000 +0200
+++ collectd_mod.pl	2009-02-20 14:23:33.000000000 +0200
@@ -41,7 +41,7 @@
 use File::Basename;
 use Getopt::Long qw(:config no_ignore_case bundling pass_through);
 
-my $DIR  = "/var/lib/collectd";
+my $DIR  = "/var/lib/collectd/rrd/hostname";
 my $HOST = undef;
 
 GetOptions (
@@ -116,7 +116,7 @@
 
 # list interesting rrd
 my @rrds;
-my @list = `ls $DIR/*.rrd`; chomp(@list);
+my @list = `find $DIR -type f -name "*.rrd"`; chomp(@list);
 
 foreach my $rrd (sort @list){
 	my $bn = basename($rrd);
@@ -142,10 +142,13 @@
 END
 
 # graph interesting rrd
-foreach my $bn (@rrds){
+foreach my $bn (@list){
 	print "$bn\n";
 
-	my $rrd = "$DIR/${bn}.rrd";
+	my $rrd = "${bn}";
+        my $int_rrd = basename($bn);
+        $int_rrd =~ s/\.rrd$//;
+
 	my $cmd = "rrdtool info $rrd |grep 'ds\\[' |sed 's/^ds\\[//'" 
 		." |sed 's/\\].*//' |sort |uniq";
 	my @dss = `$cmd`; chomp(@dss);
@@ -181,15 +184,15 @@
 
 	my $cleaned_bn = $bn; $cleaned_bn =~ s/%/_/g;
 	print OUT <<END;
-<A name="$cleaned_bn"></A><H1>$bn</H1>
+<A name="$cleaned_bn"></A><H1>$int_rrd</H1>
 END
 
 	# graph various ranges
 	foreach my $span qw(1hour 1day 1week 1month){
-		my $png = "$IMG_DIR/${bn}-$span.png";
+		my $png = "$IMG_DIR/${int_rrd}-$span.png";
 
 		my $cmd = "rrdtool graph $png"
-			." -t \"$bn $span\" --imgformat PNG --width 600 --height 100"
+			." -t \"$int_rrd $span\" --imgformat PNG --width 800 --height 120"
 			." --start now-$span --end now --interlaced"
 			." $defs >/dev/null 2>&1";
 		system($cmd);

Reply via email to