From 2caf1747f63228d28cfc004170c1d784bac15e20 Mon Sep 17 00:00:00 2001 From: Arne Baeumler Date: Mon, 8 Feb 2021 20:17:44 +0100 Subject: [PATCH] add EGLD graphing and report --- run.sh | 1 + scripts/crypto.csv | 1 + scripts/cryptoReport.pl | 2 +- scripts/getEGLD.sh | 12 ++++++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 scripts/getEGLD.sh diff --git a/run.sh b/run.sh index 348e71a..0e7f48d 100755 --- a/run.sh +++ b/run.sh @@ -1,6 +1,7 @@ #!/bin/sh /var/www/mrtg/scripts/getCryptocurrencies.sh +/var/www/mrtg/scripts/getEGLD.sh /var/www/mrtg/scripts/lxc_update.sh MRTG="/usr/bin/mrtg" diff --git a/scripts/crypto.csv b/scripts/crypto.csv index 11994c4..09be7fa 100644 --- a/scripts/crypto.csv +++ b/scripts/crypto.csv @@ -11,3 +11,4 @@ 2021-01-14;XTZ;22.784402;50;1.99;2.11;10 2021-01-14;XLM;380.6974577;100;2.99;0.2548;10 2021-01-14;ETH;0.48874273;500;7.34;1008.01;10 +2021-02-03;EGLD;35.12583900;2000;6.00;56.8242654;50 diff --git a/scripts/cryptoReport.pl b/scripts/cryptoReport.pl index 48fd1e9..e82f4b6 100755 --- a/scripts/cryptoReport.pl +++ b/scripts/cryptoReport.pl @@ -36,7 +36,7 @@ sub getCurrentPrice { sub getLastWeekValue { my ($symbol) = @_; my ($start,$step,$name,$data) = RRDs::fetch("${rrdpath}/crypto-${symbol}.rrd","AVERAGE","--start","-7d"); - return($data->[0]->[0]); + return($data->[0]->[0] || 1); } open(CSV,"<$file") or die("open($file): $!\n"); diff --git a/scripts/getEGLD.sh b/scripts/getEGLD.sh new file mode 100755 index 0000000..a039f84 --- /dev/null +++ b/scripts/getEGLD.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +RRDDIR="/var/www/localhost/rrd" +RRDPREFIX="crypto-" +TMPLDIR="/var/www/localhost/tmpl" + +EGLDBTC=$(curl -s "https://api.binance.com/api/v3/ticker/price?symbol=EGLDBTC" | jq .price | sed 's/"//g') +BTCEUR=$(curl -s "https://api.binance.com/api/v3/ticker/price?symbol=BTCEUR" | jq .price | sed 's/"//g') +SELL=$(echo $EGLDBTC $BTCEUR | awk '{printf "%.8f",$1*$2}') + +rrdtool update "${RRDDIR}/${RRDPREFIX}EGLD.rrd" N:${SELL} +