#!/usr/bin/perl # statgraph: A simple host resource graphing tool # Copyright (C) 2004-2011 Ben Charlton # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301 USA, or see http://www.gnu.org use strict; use StatGraph; use File::Copy; ## TODO: configure with getopt my $config = "statgraph.conf"; ## Get configuration open CONFIG, $config || die "Cannot open $config: $!"; my @CONFIG = (); close CONFIG; my %CONFIG = confparse(\@CONFIG); my %HOSTS = %{$CONFIG{hosts}}; %CONFIG = %{$CONFIG{config}}; ## Set default configuration options if they've not been specified my $defaultport = $CONFIG{defaultport} || 27001; my $offsets = $CONFIG{offsets} || '10800 86400 604800 2419200 31536000'; my @offsets = split(/\s+/, $offsets); my $rrdlocation = $CONFIG{rrdlocation} || "rrd/"; my $graphlocation = $CONFIG{graphlocation} || "graphs/"; open INDEX, ">$graphlocation/index.html.tmp"; print INDEX htmlheader("StatGraph results"); print INDEX "

StatGraph results

"; print INDEX "

Last updated: " . nice_date; print INDEX "

"; print INDEX htmlfooter; close INDEX; move("$graphlocation/index.html.tmp", "$graphlocation/index.html");