Update test.conf to include daily average graphs
[upsgraph] / mvrrd.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use RRDs;
5
6 sub usage {
7 print("usage: mvrrd.pl src.rrd dst.rrd start end\n");
8 }
9
10 usage() if scalar(@ARGV) != 4;
11
12 my $src = @ARGV[0];
13 my $dst = @ARGV[1];
14 my $start = $ARGV[2];
15 my $end = $ARGV[3];
16
17 sub RRDupdate {
18 my $time = shift;
19 my $val = shift;
20
21 my @arg = ();
22
23 push @arg, $dst;
24 push @arg, "$time:$val";
25 RRDs::update(@arg);
26 my $error = RRDs::error;
27 die "RRD error: $error\n" if $error;
28 }
29
30 my @arg = ();
31 push @arg, "$src";
32 push @arg, "AVERAGE";
33 push @arg, "--start", $start;
34 push @arg, "--end", $end;
35
36 my ($dataStart,$step,$names,$data) = RRDs::fetch(@arg);
37 my $error = RRDs::error;
38 die "RRD error: $error\n" if $error;
39 print "Start: ", scalar localtime($dataStart), " ($dataStart)\n";
40 print "Step size: $step seconds\n";
41 print "DS names: ", join (", ", @$names)."\n";
42 print "Data points: ", $#$data + 1, "\n";
43 print "Data:\n";
44 for my $line (@$data) {
45 # print " ", scalar localtime($dataStart), " ($dataStart) ";
46 my ($sec, $min, $hour, $mday, $mon, $year) = localtime($dataStart);
47 my $isoDate = sprintf("%04d%02d%02d", $year + 1900, $mon + 1, $mday);
48 for my $val (@$line) {
49 # printf "%f ", $val;
50 $val = 'U' if !defined $val;
51 # print "val: $val @ time $isoDate";
52 # print " ... Updating dst";
53 RRDupdate($dataStart, $val);
54 }
55 $dataStart += $step;
56 # print "\n";
57 }
Impressum, Datenschutz