From d036d16a336b8b31db2c7b09ea40012164d96a83 Mon Sep 17 00:00:00 2001 From: Benjamin Oechslein Date: Mon, 12 Jan 2015 21:37:03 +0100 Subject: [PATCH 1/1] Add option to regenerate graphs on script startup --- upsgraph.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/upsgraph.pl b/upsgraph.pl index ce19500..cade9b2 100755 --- a/upsgraph.pl +++ b/upsgraph.pl @@ -23,6 +23,7 @@ $UPSGRAPH::stepsPerHour = (60 * 60) / $UPSGRAPH::step; $UPSGRAPH::keep = ($UPSGRAPH::daysCovered*24*60*60)/$UPSGRAPH::step; $UPSGRAPH::keepHours = ($UPSGRAPH::daysCovered*24*60*60)/$UPSGRAPH::stepsPerHour/$UPSGRAPH::step; $UPSGRAPH::hosts = (); +$UPSGRAPH::regenerateOnStart = 1; #when set, regenerate graphs on script startup do $ARGV[0] or die "can't read config: $!"; @@ -427,6 +428,7 @@ die "fork failed!" if (!defined($child)); exit 0 if ($child != 0); +my $first = $UPSGRAPH::regenerateOnStart; while(1) { open(HTML, ">${outdir}/index.html.new"); @@ -503,7 +505,8 @@ while(1) { }; } - my @graphdef = ('-P', "--lazy", "-t", $hostname." - ".$vars->{$var}->{'name'}); + my @graphdef = ('-P', "-t", $hostname." - ".$vars->{$var}->{'name'}); + push @graphdef, "--lazy" if !$first; push @graphdef, "DEF:${var}-avg=${rrdfile}.${var}:${var}:AVERAGE"; push @graphdef, "DEF:${var}-min=${rrdfile}.${var}:${var}:MIN"; @@ -628,4 +631,5 @@ while(1) { rename("${outdir}/index.html.new", "${outdir}/index.html"); sleep(${step}/2); + $first = 0; } -- 2.39.2