-
Notifications
You must be signed in to change notification settings - Fork 1
/
DRAW.custom.pl
executable file
·59 lines (46 loc) · 1.32 KB
/
DRAW.custom.pl
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl -w
use strict;
my %config;
#### CONFIG SECTION ####
$config{'in'} = "Serverraum";
$config{'1'} = "Raum ITS";
$config{'2'} = "Raum Operative Leitung";
$config{'3'} = "Raum FL";
$config{'4'} = "Rezeption";
$config{'5'} = "Kueche";
$config{'datadir'} = "/srv/klimalogger/data/";
$config{'outputdir'} = "/srv/klimalogger/web/out/";
#### END CONFIG ####
my $sensor = 'in';
while ( my $db = <$config{'datadir'}/sensor_$sensor.rrd> ) {
$db =~ s/.*sensor_([\da-z]+)\.rrd.*/$1/g;
graph($db, '48h');
}
sub graph {
my ($db, $time ) = ( @_ );
my $start;
my $output_temp = $config{'outputdir'} . "/graph_${db}_${time}_Temperature.png";
if ( $time eq '48h' ) {
$start = 'end-48h';
}
my $dbalias;
if ( defined $config{$db} ) {
$dbalias = $config{$db};
} else {
$dbalias = $db;
}
my $cmd = "rrdtool graph $output_temp \\
-w 650 \\
-h 160 \\
--end now \\
--start $start \\
--vertical-label=\"Degree Celsius\" \\
DEF:temp=$config{'datadir'}/sensor_${db}.rrd:temp:AVERAGE \\
LINE2:temp#FF0000:\"Temperature\" \\
GPRINT:temp:MIN:\" Min\\: %4.1lf\" \\
GPRINT:temp:MAX:\" Max\\: %4.1lf\" \\
GPRINT:temp:AVERAGE:\" Avg\\: %4.1lf\" \\
-t \" $time - Sensor $dbalias (Temperature) \" ";
#print $cmd;
system( $cmd . " > /dev/null");
}