Thread Array in Variable (15 answers)
Opened by NetFritz at 2015-11-30 19:12

NetFritz
 2015-12-02 20:47
#183137 #183137
User since
2015-03-05
10 Artikel
BenutzerIn
[default_avatar]
Hallo
Ich habe es hinbekommen.
Eine Matrix aus 2-dimensionalen Arrays.
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/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;

Vielen Dank für die Hilfe.
Gruß NetFritz

View full thread Array in Variable