X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=contrib%2Fcollectd2html.pl;h=ab22bf97be48dc88500ebe3ecf5910708ba76191;hb=a37c766a9309e6efe7653d81fe4c44d6dc5b0af8;hp=32d6305592981b7f27ace786051834f52c42fc72;hpb=c5470f98e71c4f73e3b2f85d17c21d24fccaf156;p=collectd.git 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 <