#!/usr/bin/perl # use strict; use RRDs; use InfluxDB; use Data::Dumper; my @rrd_array; my $DB = "/var/www/rrd/PVGIS_forecast.rrd"; my $start = "midnight+6h"; # Mitternacht+6h my $end = "noon+9h"; # Mittag+9h my ($start, $step, $columns,$data) = RRDs::fetch($DB, "--start=$start", "--end=$end", "AVERAGE") or die "Cannot fetch rrd ($RRDs::error)"; my $ii = 0; OUTER:foreach my $line (@$data) { $start += $step; INNER:foreach my $val (@$line) { $val = "N/A" unless defined $val; if($val eq "N/A"){last OUTER;} $rrd_array[$ii][0] = ($start); $rrd_array[$ii][1] = ($val); ++$ii; } } my @matrix=(@rrd_array); #print Dumper(@matrix); # my $ix = InfluxDB->new( host => '127.0.0.1', port => 8086, username => 'root', password => 'root', database => 'pv_wetter', ); $ix->write_points( data => { name => "test", columns => [qw(time forecast)], points => \@matrix, }, ) or die "write_points: " . $ix->errstr; my $rs = $ix->query( q => 'select * from test ', time_precision => 's', ) or die "query: " . $ix->errstr;