html crypto report
This commit is contained in:
71
scripts/cryptoReport.pl
Executable file
71
scripts/cryptoReport.pl
Executable file
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
use strict;
|
||||
use warnings;
|
||||
use RRDs;
|
||||
use Data::Dumper;
|
||||
use Template;
|
||||
|
||||
my $file = $ARGV[0] or die("Usage: $0 csv\n");
|
||||
|
||||
my $rrdpath = "/var/www/localhost/rrd";
|
||||
my $cryptoMap = {
|
||||
"AAVE" => "AAVE",
|
||||
"ALGO" => "Algorand",
|
||||
"BTC" => "Bitcoin",
|
||||
"CVC" => "Civic",
|
||||
"DNT" => "district0x",
|
||||
"EGLD" => "Elrond eGold",
|
||||
"ETH" => "Etherium",
|
||||
"LRC" => "Loopring",
|
||||
"REN" => "REN",
|
||||
"SNX" => "Synthetix",
|
||||
"XLM" => "Stellar Lumen",
|
||||
"XTZ" => "Tezos"
|
||||
};
|
||||
my $v;
|
||||
|
||||
$v->{GENERATED} = localtime;
|
||||
|
||||
sub getCurrentPrice {
|
||||
my ($symbol) = @_;
|
||||
my ($start,$step,$name,$data) = RRDs::fetch("${rrdpath}/crypto-${symbol}.rrd","LAST","--start","-10m");
|
||||
return($data->[0]->[0]);
|
||||
}
|
||||
|
||||
sub getLastWeekValue {
|
||||
my ($symbol) = @_;
|
||||
my ($start,$step,$name,$data) = RRDs::fetch("${rrdpath}/crypto-${symbol}.rrd","AVERAGE","--start","-7d");
|
||||
return($data->[0]->[0]);
|
||||
}
|
||||
|
||||
open(CSV,"<$file") or die("open($file): $!\n");
|
||||
|
||||
while (<CSV>) {
|
||||
my ($date,$currency,$coin,$price,$fee,$buyrate,$selltresh) = split /;/;
|
||||
my $x = {
|
||||
DATE => $date,
|
||||
NAME => $cryptoMap->{$currency},
|
||||
CURRENCY => $currency,
|
||||
COIN => $coin,
|
||||
PRICE => $price,
|
||||
FEE => $fee,
|
||||
BUYRATE => $buyrate,
|
||||
};
|
||||
$x->{CURRENT_PRICE} = &getCurrentPrice($currency);
|
||||
$x->{LAST_WEEK_PRICE} = &getLastWeekValue($currency);
|
||||
$x->{IMAGE} = `curl -s 'http://localhost/cgi-bin/graph.pl?width=540&height=200&graph=crypto-${currency}&start=-14d' --output - | base64 -w 0`;
|
||||
push @{$v->{DATA}},$x;
|
||||
}
|
||||
|
||||
close(CSV);
|
||||
|
||||
my $template = Template->new({
|
||||
INCLUDE_PATH => '/var/www/localhost/tmpl',
|
||||
INTERPOLATE => 1,
|
||||
});
|
||||
|
||||
$|++;
|
||||
$template->process('cryptoReport.tmpl',$v) or die($!);
|
||||
print "\n";
|
||||
#print Dumper($v);
|
6
scripts/mail-header
Normal file
6
scripts/mail-header
Normal file
@ -0,0 +1,6 @@
|
||||
To: baeumler85@gmx.net, arne@br0tkasten.de
|
||||
Subject: "Crypto Report"
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/html
|
||||
Content-Disposition: inline
|
||||
|
Reference in New Issue
Block a user