1 |
#!/bin/env perl |
#!/usr/bin/perl |
2 |
############################################################ |
############################################################ |
3 |
# |
# |
4 |
# $Id: rrd-server.pl 1092 2008-01-23 14:23:51Z nicolaw $ |
# $Id: rrd-server.pl 1092 2008-01-23 14:23:51Z nicolaw $ |
23 |
|
|
24 |
BEGIN { |
BEGIN { |
25 |
# User defined constants |
# User defined constants |
26 |
use constant BASEDIR => '/home/nicolaw/webroot/www/rrd.me.uk'; |
use constant BASEDIR => '/var/www/rrd'; |
27 |
use constant THEME => ('BACK#F5F5FF','SHADEA#C8C8FF','SHADEB#9696BE', |
use constant THEME => ('BACK#F5F5FF','SHADEA#C8C8FF','SHADEB#9696BE', |
28 |
'ARROW#61B51B','GRID#404852','MGRID#67C6DE'); |
'ARROW#61B51B','GRID#404852','MGRID#67C6DE'); |
29 |
} |
} |
59 |
my %opt = (); |
my %opt = (); |
60 |
$Getopt::Std::STANDARD_HELP_VERSION = 1; |
$Getopt::Std::STANDARD_HELP_VERSION = 1; |
61 |
$Getopt::Std::STANDARD_HELP_VERSION = 1; |
$Getopt::Std::STANDARD_HELP_VERSION = 1; |
62 |
Getopt::Std::getopts('u:G:T:gthvVf?', \%opt); |
Getopt::Std::getopts('r:u:G:T:gthvVf?', \%opt); |
63 |
|
|
64 |
$opt{g} ||= $opt{G}; |
$opt{g} ||= $opt{G}; |
65 |
$opt{t} ||= $opt{T}; |
$opt{t} ||= $opt{T}; |
67 |
# Display help or version |
# Display help or version |
68 |
(VERSION_MESSAGE() && exit) if defined $opt{v}; |
(VERSION_MESSAGE() && exit) if defined $opt{v}; |
69 |
(HELP_MESSAGE() && exit) if defined $opt{h} || defined $opt{'?'} || |
(HELP_MESSAGE() && exit) if defined $opt{h} || defined $opt{'?'} || |
70 |
!(defined $opt{u} || defined $opt{g} || defined $opt{t}); |
!(defined $opt{u} || defined $opt{g} || defined $opt{t} || defined $opt{r}); |
71 |
|
|
72 |
# cd to the righr location and define directories |
# cd to the righr location and define directories |
73 |
chdir BASEDIR || die sprintf("Unable to chdir to '%s': %s", BASEDIR, $!); |
chdir BASEDIR || die sprintf("Unable to chdir to '%s': %s", BASEDIR, $!); |
82 |
memoize('basename'); |
memoize('basename'); |
83 |
memoize('graph_def'); |
memoize('graph_def'); |
84 |
|
|
85 |
|
if ( my $hostname = $opt{r} ) { |
86 |
|
warn "# refresh $hostname\n"; |
87 |
|
$opt{V} = 1; |
88 |
|
create_thumbnails($rrd,\%dir,$hostname); |
89 |
|
create_graphs($rrd,\%dir,$hostname); |
90 |
|
exit; |
91 |
|
} |
92 |
|
|
93 |
# Update the RRD if we've been asked to |
# Update the RRD if we've been asked to |
94 |
my $hostname = defined $opt{u} ? update_rrd($rrd,\%dir,$opt{u}) : undef; |
my $hostname = defined $opt{u} ? update_rrd($rrd,\%dir,$opt{u}) : undef; |
95 |
|
|