>>>>> Sebastian Harl <[EMAIL PROTECTED]> writes:

 >> Please consider the following patch.

 >> $ diff -u \
 >>       <(zcat /usr/share/doc/collectd/examples/collectd2html.pl.gz) \
 >>       collectd2html.pl

 > I'm quite surprised to get a patch for that script. It has never been
 > ported to version 4 of collectd and should not work at all right
 > now.

        But it works, although the invocation and semantics obviously
        did change, e. g.:

$ perl collectd2html.pl --data-dir=/var/lib/collectd/rrd/HOSTNAME/processes 

 > I was actually going to remove it entirely from the package but must
 > have forgotten about it.

 > Did you update the script to work with version 4? If so, please
 > provide those patches as well.

        Actually, I'm using a wrapper script right now, like:

#!/bin/bash
set -e -x
h=HOSTNAME
collectd2html=/where/is/collectd2html.pl
rrd=/var/lib/collectd/rrd

for i in "$rrd"/"$h"/* ; do
    o="$(basename "$i")"

    if [ -e "$o"/"$h" ] ; then
        continue
    fi

    mkdir -pv -- "$o"
    (cd "$o" \
         && $collectd2html --host="$h" --data-dir="$i" \
                --image-format=SVG)
done

        Should collectd2html.pl to be patched, it should probably allow
        for the set of subdirectories to process to be specified via the
        command line.

 >>  GetOptions (
 >>      "host=s"     => \$HOST,
 >> -    "data-dir=s" => \$DIR
 >> +    "data-dir=s" => \$DIR,
 >> +   "image-format=s" => \$IMG_FMT
 >>  );
 > [...]
 >> +my $svg_p = ($IMG_FMT eq "SVG");
 >> +my $IMG_SFX = $svg_p ? ".svg" : ".png";

 > Currently, all image formats supported by rrdtool (svg, ps and pdf
 > iirc) do require special handling in the HTML output (e.g. just
 > include a link for the ps and pdf formats) - could you please extent
 > your patch to handle that as well? TIA.

        My patch already treats SVG specifically:

-               my $cleaned_png = $png; $cleaned_png =~ s/%/%25/g;
-               print OUT <<END;
-<P><IMG src="$cleaned_png" alt="${bn} $span"></P>
+               my $cleaned_img = $img; $cleaned_img =~ s/%/%25/g;
+               if (! $svg_p) {
+                       print OUT <<END;
+<P><IMG src="$cleaned_img" alt="${bn} $span"></P>
+END
+               } else {
+                       print OUT <<END;
+<P><object data="$cleaned_img" type="image/svg+xml"
+           width="670" height="179"><!-- Huh? -->
+  ${bn} $span</object></P>
 END
+               }

        I guess that PostScript could be referenced with <img> (if the
        browser used supports inline PostScript images.)  I don't know
        if it would work with PDF.




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to