61 lines
1.7 KiB
Plaintext
61 lines
1.7 KiB
Plaintext
$NetBSD: patch-aa,v 1.2 2010/12/06 12:38:27 triaxx Exp $
|
|
|
|
Update version
|
|
Change hostname to a real name
|
|
Delete comments which are not understoop by rdd
|
|
Create temp directory
|
|
|
|
--- bindgraph.cgi.orig 2003-05-04 22:26:18.000000000 +0000
|
|
+++ bindgraph.cgi
|
|
@@ -9,12 +9,12 @@
|
|
use RRDs;
|
|
use strict;
|
|
|
|
-my $VERSION = '0.1';
|
|
+my $VERSION = '0.2';
|
|
|
|
# hostname. will be printed in the HTML page
|
|
-my $hostname = 'hostname.example.net (please edit bindgraph.cgi)';
|
|
+my $hostname = "$ENV{HTTP_HOST}";
|
|
# path of the RRD database
|
|
-my $rrd = '/var/www/as112/rrd/bindgraph.rrd';
|
|
+my $rrd = '@RRDDIR@/bindgraph.rrd';
|
|
# temporary directory where the images will be saved
|
|
my $tmp_dir = '/tmp/bindgraph';
|
|
|
|
@@ -89,6 +89,10 @@ sub graph($$$;$) {
|
|
}
|
|
}
|
|
|
|
+ my $last_update = localtime(last_update($rrd));
|
|
+ $last_update =~ s|:|\\:|g unless $RRDs::VERSION < 1.199908;
|
|
+ my $date = localtime(time);
|
|
+ $date =~ s|:|\\:|g unless $RRDs::VERSION < 1.199908;
|
|
my ($text, $xs, $ys) = RRDs::graph(
|
|
$file,
|
|
'--imgformat', 'PNG',
|
|
@@ -101,9 +105,8 @@ sub graph($$$;$) {
|
|
'--lazy',
|
|
@rrdef,
|
|
@rrprint,
|
|
- 'COMMENT:\s',
|
|
- 'COMMENT:last update: ' . localtime(last_update($rrd))
|
|
- . ' graph created on ' . localtime(time) . '\r',
|
|
+ 'COMMENT:last update\: ' . $last_update
|
|
+ . ' graph created on ' . $date . '\r',
|
|
);
|
|
my $err = RRDs::error;
|
|
die_fatal("RRDs::graph($file, ...): $err") if $err;
|
|
@@ -209,7 +212,10 @@ sub main {
|
|
$uri =~ s#/#,#g;
|
|
$uri =~ s#~#tilde,#g;
|
|
|
|
- die_fatal("ERROR: $tmp_dir does not exist") if not -d $tmp_dir;
|
|
+ if (not -d "$tmp_dir") {
|
|
+ mkdir("$tmp_dir", 0777)
|
|
+ or die_fatal("ERROR: cannot create $tmp_dir: $!");
|
|
+ }
|
|
|
|
if (not -d "$tmp_dir/$uri") {
|
|
mkdir("$tmp_dir/$uri", 0777)
|