From a095d4f8e3917cca8a989bf1d8f0a6979a3d9652 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Eddy=20Petri=C8=99or?= Date: Wed, 22 Aug 2007 17:15:34 +0200 Subject: [PATCH] contrib/collectd2html.pl: Allow generation of graphs from remote hosts or in an alternative directory. In the contribs area of the package there is a nice collectd2html.pl script which assumes that the data is present in /var/lib/collectd and infers the hostname. All fine and dandy, but there is no way to override this. This is useful if one generates the data on a machine, but generates the graphs on another one. With the attached patch now is possible to specify a different host and/or a different directory for the data. The added options are '--host-is' and '--data-dir'. An invocation for a remote host whose rrd files have been placed in /var/tmp/collectd-remoteh looks like: collectd2html.pl --host-is=remoteh --data-dir=/var/tmp/collectd-remoteh --- contrib/collectd2html.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/contrib/collectd2html.pl b/contrib/collectd2html.pl index 6ff1c479..a4cfe3ab 100644 --- a/contrib/collectd2html.pl +++ b/contrib/collectd2html.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w ################################################################################ # @@ -36,12 +36,20 @@ use warnings; use strict; use Fatal qw(open close); use File::Basename; +use Getopt::Long qw(:config no_ignore_case bundling pass_through); + +my $DIR = "/var/lib/collectd"; +my $HOST = "_UNDEFINED_"; + +GetOptions ( + "host-is=s" => \$HOST, + "data-dir=s" => \$DIR +); -my $DIR = "/var/lib/collectd"; my @COLORS = (0xff7777, 0x7777ff, 0x55ff55, 0xffcc77, 0xff77ff, 0x77ffff, 0xffff77, 0x55aaff); my @tmp = `/bin/hostname`; chomp(@tmp); -my $HOST = $tmp[0]; +$HOST = $tmp[0] if ( $HOST =~ /_UNDEFINED_/ ); my $IMG_DIR = "${HOST}.dir"; my $HTML = "${HOST}.html"; -- 2.11.0