init III
This commit is contained in:
19
Perl Luftdaten/26940_26941/archive.html
Normal file
19
Perl Luftdaten/26940_26941/archive.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<html>
|
||||
<body>
|
||||
<h2>Temperature</h2>
|
||||
<a href='graph-Temperature-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Temperature-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM10</h2>
|
||||
<a href='graph-PM10-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM10-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>PM25</h2>
|
||||
<a href='graph-PM25-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-PM25-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>Humidity</h2>
|
||||
<a href='graph-Humidity-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-Humidity-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
<h2>hPa</h2>
|
||||
<a href='graph-hPa-2020-01-18.png' target='_archive'>2020-01-18</a>
|
||||
<a href='graph-hPa-2020-01-19.png' target='_archive'>2020-01-19</a>
|
||||
</body>
|
||||
</html>
|
||||
1
Perl Luftdaten/26940_26941/here
Normal file
1
Perl Luftdaten/26940_26941/here
Normal file
@@ -0,0 +1 @@
|
||||
<a href='https://wego.here.com/directions/mix/50.126,8.696/?map=50.126,8.696,16,normal' target='_map'>wego.here</a>
|
||||
30
Perl Luftdaten/26940_26941/mkarchive.sh
Normal file
30
Perl Luftdaten/26940_26941/mkarchive.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /var/www/html/26940_26941
|
||||
export archfile=archive.html
|
||||
|
||||
function ech () {
|
||||
echo "$1" >> $archfile
|
||||
}
|
||||
|
||||
:>$archfile
|
||||
|
||||
ech "<html>"
|
||||
ech "<body>"
|
||||
|
||||
export vals="Temperature PM10 PM25 Humidity hPa"
|
||||
|
||||
for J in `echo $vals`
|
||||
do
|
||||
ech "<h2>$J</h2>"
|
||||
for I in `ls *.png | egrep "^graph-$J-[0-9]{4}"`
|
||||
do
|
||||
dat=`echo $I | egrep -o "[0-9]{4}-[0-9]{2}-[0-9]{2}"`
|
||||
ech "<a href='$I' target='_archive'>$dat</a>"
|
||||
done
|
||||
done
|
||||
|
||||
ech "</body>"
|
||||
ech "</html>"
|
||||
|
||||
|
||||
60
Perl Luftdaten/26940_26941/read_multiple.pl
Normal file
60
Perl Luftdaten/26940_26941/read_multiple.pl
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use LWP::Simple; # From CPAN
|
||||
use JSON qw( decode_json ); # From CPAN
|
||||
use Data::Dumper; # Perl core module
|
||||
use strict; # Good practice
|
||||
use warnings; # Good practice
|
||||
|
||||
my $rrdfile="/scripts/luftdaten/26940_26941/db_26940_26941.rrd";
|
||||
|
||||
my $sensor;
|
||||
my $trendsurl;
|
||||
my $json;
|
||||
my $decoded_json;
|
||||
my $k;
|
||||
|
||||
my $PM10;
|
||||
my $PM25;
|
||||
my $TEMP;
|
||||
my $HUMI;
|
||||
my $LON;
|
||||
my $LAT;
|
||||
|
||||
my $i;
|
||||
|
||||
for ($i=1; $i<=3; $i++) {
|
||||
$sensor=26940;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
print "$k->{'timestamp'}\n";
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$PM10 = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$PM25 = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
$LAT = $k->{'location'}->{'latitude'};
|
||||
$LON = $k->{'location'}->{'longitude'};
|
||||
|
||||
open FILE, ">/scripts/luftdaten/26940_26941/here";
|
||||
printf FILE "<a href='https://wego.here.com/directions/mix/$LAT,$LON/?map=$LAT,$LON,16,normal' target='_map'>wego.here</a>";
|
||||
close FILE;
|
||||
$sensor=26941;
|
||||
$trendsurl = "https://api.luftdaten.info/v1/sensor/$sensor/";
|
||||
$json = get( $trendsurl );
|
||||
die "Could not get $trendsurl!" unless defined $json;
|
||||
$decoded_json = decode_json( $json );
|
||||
|
||||
$k=${$decoded_json}[0];
|
||||
printf "%-20s %6.2f\n", $k->{'sensordatavalues'}[0]->{'value_type'}, $k->{'sensordatavalues'}[0]->{'value'};
|
||||
printf "%-20s %6.2f\n\n", $k->{'sensordatavalues'}[1]->{'value_type'}, $k->{'sensordatavalues'}[1]->{'value'};
|
||||
$TEMP = $k->{'sensordatavalues'}[0]->{'value'};
|
||||
$HUMI = $k->{'sensordatavalues'}[1]->{'value'};
|
||||
|
||||
`/usr/bin/rrdtool update $rrdfile N:$PM25:$PM10:$TEMP:$HUMI:U`;
|
||||
sleep (30);
|
||||
}
|
||||
150
Perl Luftdaten/26940_26941/write_graph.sh
Normal file
150
Perl Luftdaten/26940_26941/write_graph.sh
Normal file
@@ -0,0 +1,150 @@
|
||||
#!/bin/bash
|
||||
|
||||
function graph () {
|
||||
rrdtool graph "graph-$VALUE-$SPAN.png" \
|
||||
--title "$VALUE ($SPAN)" \
|
||||
--vertical-label "$UNIT" \
|
||||
--width '600' \
|
||||
--height '200' \
|
||||
--start end-$SPAN \
|
||||
"DEF:VNAME=db_26940_26941.rrd:$VALUE:MAX" \
|
||||
'VDEF:vmin=VNAME,MINIMUM' \
|
||||
'VDEF:vmax=VNAME,MAXIMUM' \
|
||||
'VDEF:vavg=VNAME,AVERAGE' \
|
||||
'VDEF:vlast=VNAME,LAST' \
|
||||
'LINE1:VNAME#0000FF' \
|
||||
'GPRINT:vmin:%3.1lf (min)' \
|
||||
'GPRINT:vmax:%3.1lf (max)' \
|
||||
'GPRINT:vavg:%3.1lf (avg)' \
|
||||
'GPRINT:vlast:%3.1lf (last)'
|
||||
}
|
||||
|
||||
cd /scripts/luftdaten/26940_26941/
|
||||
|
||||
export SPAN=1h
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1d
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
export TIM=`date +"%H:%M"`
|
||||
if [ "$TIM" == "23:55" ]
|
||||
then
|
||||
export DAT=`date +"%Y-%m-%d"`
|
||||
cp graph-Temperature-1d.png graph-Temperature-$DAT.png
|
||||
cp graph-Humidity-1d.png graph-Humidity-$DAT.png
|
||||
cp graph-hPa-1d.png graph-hPa-$DAT.png
|
||||
cp graph-PM10-1d.png graph-PM10-$DAT.png
|
||||
cp graph-PM25-1d.png graph-PM25-$DAT.png
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1w
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1m
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
|
||||
|
||||
|
||||
|
||||
export SPAN=1y
|
||||
|
||||
export VALUE=Humidity
|
||||
export UNIT=%
|
||||
graph
|
||||
|
||||
export VALUE=Temperature
|
||||
export UNIT=°C
|
||||
graph
|
||||
|
||||
export VALUE=PM10
|
||||
export UNIT=µg
|
||||
graph
|
||||
|
||||
export VALUE=PM25
|
||||
graph
|
||||
|
||||
export VALUE=hPa
|
||||
export UNIT=hPa
|
||||
graph
|
||||
Reference in New Issue
Block a user