From: Ivan Shmakov Date: Wed, 21 May 2008 10:40:04 +0000 (+0700) Subject: collectd2html.pl: Allow for --imgformat to be passed to rrdtool. X-Git-Tag: collectd-4.6.4~9 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a37c766a9309e6efe7653d81fe4c44d6dc5b0af8;p=collectd.git collectd2html.pl: Allow for --imgformat to be passed to rrdtool. This was reported as Debian bug #482185. Signed-off-by: Sebastian Harl --- diff --git a/contrib/collectd2html.pl b/contrib/collectd2html.pl index 32d63055..ab22bf97 100644 --- a/contrib/collectd2html.pl +++ b/contrib/collectd2html.pl @@ -43,16 +43,20 @@ use Getopt::Long qw(:config no_ignore_case bundling pass_through); my $DIR = "/var/lib/collectd"; my $HOST = undef; +my $IMG_FMT = "PNG"; GetOptions ( "host=s" => \$HOST, - "data-dir=s" => \$DIR + "data-dir=s" => \$DIR, + "image-format=s" => \$IMG_FMT ); my @COLORS = (0xff7777, 0x7777ff, 0x55ff55, 0xffcc77, 0xff77ff, 0x77ffff, 0xffff77, 0x55aaff); my @tmp = `/bin/hostname`; chomp(@tmp); $HOST = $tmp[0] if (! defined $HOST); +my $svg_p = ($IMG_FMT eq "SVG"); +my $IMG_SFX = $svg_p ? ".svg" : ".png"; my $IMG_DIR = "${HOST}.dir"; my $HTML = "${HOST}.html"; @@ -186,18 +190,26 @@ END # graph various ranges foreach my $span qw(1hour 1day 1week 1month){ - my $png = "$IMG_DIR/${bn}-$span.png"; + my $img = "$IMG_DIR/${bn}-$span$IMG_SFX"; - my $cmd = "rrdtool graph $png" - ." -t \"$bn $span\" --imgformat PNG --width 600 --height 100" + my $cmd = "rrdtool graph $img" + ." -t \"$bn $span\" --imgformat $IMG_FMT --width 600 --height 100" ." --start now-$span --end now --interlaced" ." $defs >/dev/null 2>&1"; system($cmd); - my $cleaned_png = $png; $cleaned_png =~ s/%/%25/g; - print OUT <${bn} $span

+ my $cleaned_img = $img; $cleaned_img =~ s/%/%25/g; + if (! $svg_p) { + print OUT <${bn} $span

END + } else { + print OUT < + ${bn} $span

+END + } } print OUT <