From 813917648686533b4878d7a8920785f618e15e2e Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 27 Jul 2008 13:08:28 +0200 Subject: [PATCH] contrib/collection3: Updated the `collection3' stuff in contrib/. --- contrib/collection3/bin/graph.cgi | 28 ++++- contrib/collection3/bin/index.cgi | 63 +++++++++++- .../etc/{collection3.conf => collection.conf} | 30 ++++++ .../lib/Collectd/Graph/Type/GenericStacked.pm | 18 +++- contrib/collection3/share/navigate.js | 113 +++++++++++++++++++++ contrib/collection3/share/style.css | 70 +++++++++++++ 6 files changed, 311 insertions(+), 11 deletions(-) rename contrib/collection3/etc/{collection3.conf => collection.conf} (87%) create mode 100644 contrib/collection3/share/navigate.js diff --git a/contrib/collection3/bin/graph.cgi b/contrib/collection3/bin/graph.cgi index c84199df..08557b47 100755 --- a/contrib/collection3/bin/graph.cgi +++ b/contrib/collection3/bin/graph.cgi @@ -18,6 +18,7 @@ use Collectd::Graph::Type (); our $Debug = param ('debug'); our $Begin = param ('begin'); our $End = param ('end'); +our $GraphWidth = param ('width'); if ($Debug) { @@ -27,7 +28,7 @@ Content-Type: text/plain HTTP } -tl_read_config ("$RealBin/../etc/collection3.conf"); +tl_read_config ("$RealBin/../etc/collection.conf"); { # Sanitize begin and end times $End ||= 0; @@ -93,15 +94,29 @@ for (@$files) } my $expires = time (); +# IF (End is `now') +# OR (Begin is before `now' AND End is after `now') if (($End == 0) || (($Begin <= $expires) && ($End >= $expires))) { # 400 == width in pixels - my $timespan = $expires - $Begin; - $expires += int ($timespan / 400); + my $timespan; + + if ($End == 0) + { + $timespan = $expires - $Begin; + } + else + { + $timespan = $End - $Begin; + } + $expires += int ($timespan / 400.0); } +# IF (End is not `now') +# AND (End is before `now') +# ==> Graph will never change again! elsif (($End > 0) && ($End < $expires)) { - $expires += 366 * 86400; + $expires += (366 * 86400); } elsif ($Begin > $expires) { @@ -112,6 +127,11 @@ print STDOUT header (-Content_type => 'image/png', -Last_Modified => epoch_to_rfc1123 ($obj->getLastModified ()), -Expires => epoch_to_rfc1123 ($expires)); +if ($Debug) +{ + print "\$expires = $expires;\n"; +} + my $args = $obj->getRRDArgs (0); if ($Debug) diff --git a/contrib/collection3/bin/index.cgi b/contrib/collection3/bin/index.cgi index b0001d26..d8059df0 100755 --- a/contrib/collection3/bin/index.cgi +++ b/contrib/collection3/bin/index.cgi @@ -57,7 +57,7 @@ if (!exists ($Actions{$action})) exit 1; } -tl_read_config ("$RealBin/../etc/collection3.conf"); +tl_read_config ("$RealBin/../etc/collection.conf"); $Actions{$action}->(); exit (0); @@ -107,6 +107,14 @@ sub start_html { return if ($html_started); + my $end; + my $begin; + my $timespan; + + $end = time (); + $timespan = get_timespan_selection (); + $begin = $end - $timespan; + if (can_handle_xhtml ()) { print <collection.cgi, Version 3 +