SHOW:
|
|
- or go back to the newest paste.
1 | #!/bin/bash | |
2 | # Ethermine.org stats and power cost calculations script | |
3 | # | |
4 | # v0.1 proof of concept | |
5 | # v0.2 adds time to next Ether calculation with human-friendly timeframe and datestamps | |
6 | # adds number padding to prettify output and permit later addition of multiple currencies | |
7 | # reordered output for aesthetic reasons; tabbed data first | |
8 | # adds separate padding function for fiat currencies; work to two decimal places | |
9 | # v0.3 brings energy cost calcs into a function, avoids dependence on a separate script | |
10 | # - despite the variable names, this supports any input currency known to fixer.io | |
11 | # - simplified function to avoid needing external commands to extract data from it | |
12 | # - adds power reporting in kWh, not just USD power cost | |
13 | # v0.4 improves multi-currency support | |
14 | # - fetch a currency conversion rate for power costs only if currency != USD | |
15 | # - fetch currency conversion data once per script run, not recursively within functions | |
16 | # - add functions to return a conversion from USD to local currency and vice versa | |
17 | # - add conversion of gross returns to local currency in which power cost is given | |
18 | # - show the conversion rate from local to USD alongside | |
19 | # - add reporting of power costs in local currency before USD conversion | |
20 | # - add conversion of net returns to local currency | |
21 | # - tested with USD, GBP, CAD, AUD, EUR, others probably work | |
22 | # v0.5 improves relevance of output in light of multi-currency support | |
23 | # - suppress redundant output where currency = USD, use local currency when relevant | |
24 | # - show currency conversion workings alongside returns in local currency | |
25 | # - suppress redundant output where currency != USD and workings shown alongside | |
26 | # - suppress 4 lines of output for power costs in non-local currency | |
27 | # - suppress 4 lines of output for power costs in kWh; workings alongside fiat costs | |
28 | # - process work data from last 100 rounds for average hashrate | |
29 | # - tidy up the output | |
30 | # v0.6 - if we have a /tmp/wattage file, let it override the command line variable. This | |
31 | # allows us to vary the specified wattage on the fly once the script is running e.g. | |
32 | # when running in screen, basically to set wattage in line with variable rig usage | |
33 | # or clock speeds. | |
34 | # - add calculation for watts per MH/s | |
35 | # - add more explanatory notes as to data sources; add long padding function | |
36 | # v0.7 Fixed average hash rate to use the 24h average from the pool rather than data from | |
37 | # the last 100 rounds. Oops. Tidied up formatting a bit, prettified. Still no worker | |
38 | # data as yet; this is pitched at global statistics so far. | |
39 | # - suppress redundant currency conversions in power costs | |
40 | # - add net estimate calculations for ETH and BTC values alongside gross estimates | |
41 | # v0.8 Adds support for output equivalents in altcoin using the ShapeShift HTTP API. The | |
42 | # initial implementation adds an ETH-DASH conversion for comparison with X11 mining. | |
43 | # - change description to "exchange" where a third-party exchange rate is involved | |
44 | # - add exchange rate for BTC from Shapeshift.io; see how far it deviates from pool | |
45 | # - add exchange rate for XMR from Shapeshift.io, because we can | |
46 | # - support addresses with or without a leading 0x | |
47 | # - add some help text, trigger it on improper or inadequate input | |
48 | # - removed surplus blank lines | |
49 | version="0.8"; | |
50 | watts=$2; | |
51 | [ -r /tmp/wattage ] && watts=`cat /tmp/wattage`; | |
52 | function help { | |
53 | echo ""; | |
54 | echo "Usage: ./ethermine_stats <address> <total_wattage> <cost_per_kwh> <currency_code>"; | |
55 | echo ""; | |
56 | echo "where"; | |
57 | echo ""; | |
58 | echo "<address> your miner address as used at the pool"; | |
59 | echo "<total_wattage> power consumption in watts of the mining rigs on this address"; | |
60 | echo "<cost_per_kwh> as a decimal price per kWh, such as 0.10629 or whatever"; | |
61 | echo "<currency_code> your local currency: USD, GBP, EUR, CAD, AUD etc."; | |
62 | echo ""; | |
63 | echo "You can use expressions for cost_per_kWh, such as 0.10629*1.05*0.98, if for instance"; | |
64 | echo "you have a base cost per kWh on which you pay 5% VAT but get 2% cashback on the total"; | |
65 | echo "amount (as happens to apply to the author). Examples:"; | |
66 | echo "" | |
67 | echo "./ethermine_stats 0xc91B3f6a889a9963c7eaE2d5BD5Ca88a6Ae2d2EA 506 0.10629*1.05*0.98 GBP" | |
68 | echo ""; | |
69 | echo "./ethermine_stats 0xc91B3f6a889a9963c7eaE2d5BD5Ca88a6Ae2d2EA 500 0.12 USD" | |
70 | echo ""; | |
71 | echo "./ethermine_stats 0xc91B3f6a889a9963c7eaE2d5BD5Ca88a6Ae2d2EA 500 0.14 EUR" | |
72 | echo ""; | |
73 | echo "The intention is that this script will typically be run at regular intervals, such as"; | |
74 | echo "with 'watch -n60 ./ethermine_stats [args]' and that it should remain compatible with"; | |
75 | echo "such use as part of a 'screen' session running ethminer and a host of other scripts."; | |
76 | echo "" | |
77 | echo "For the same reason, output is sized to fit in one page of a 140-character (or more)" | |
78 | echo "terminal window. More functionality is planned, including per-worker statistics, use" | |
79 | echo "of payouts data and potentially interfaces to other third-party services, but these" | |
80 | echo "will most likely be implemented as separate functions to the main statistics page." | |
81 | } | |
82 | function lineohash { | |
83 | for ((i=0;i<139;i++)); do echo -n "#"; done; echo "#"; | |
84 | } | |
85 | function lineodash { | |
86 | for ((i=0;i<139;i++)); do echo -n "-"; done; echo "-"; | |
87 | } | |
88 | lineodash | |
89 | echo "ethermine.org pool, power and profitability statistics for Linux, version $version (`date`)" | |
90 | lineodash | |
91 | [[ "$4" == "" ]] && help && exit 0; | |
92 | [[ "$3" == "" ]] && help && exit 0; | |
93 | [[ "$2" == "" ]] && help && exit 0; | |
94 | [[ "$1" == "" ]] && help && exit 0; | |
95 | function energycosts { | |
96 | WATTS=$1 | |
97 | PERKWH=$2 | |
98 | CUR=$3 | |
99 | VAR=$4 | |
100 | GBPKWH="`bc <<< "scale=6; x=$PERKWH; if(x<1) print 0; x"`"; | |
101 | [[ "$CUR" == "USD" ]] && GBPTOUSD="1.0" || GBPTOUSD=$(loc2usd 1); | |
102 | USDKWH="`bc <<< "scale=6; x=$PERKWH*$GBPTOUSD; if(x<1) print 0; x"`"; | |
103 | KWHDAY="`/usr/bin/bc <<< "scale=3; x=$WATTS*24/1000; if(x<1) print 0; x"`"; | |
104 | USDDAY="`/usr/bin/bc <<< "scale=2; x=$KWHDAY*$USDKWH/1; if(x<1) print 0; x"`"; | |
105 | GBPDAY="`/usr/bin/bc <<< "scale=2; x=$KWHDAY*$GBPKWH/1; if(x<1) print 0; x"`"; | |
106 | KWHWEEK="`/usr/bin/bc <<< "scale=3; x=$WATTS*24*7/1000; if(x<1) print 0; x"`"; | |
107 | USDWEEK="`/usr/bin/bc <<< "scale=2; x=$KWHDAY*$USDKWH*7/1; if(x<1) print 0; x"`"; | |
108 | GBPWEEK="`/usr/bin/bc <<< "scale=2; x=$KWHDAY*$GBPKWH*7/1; if(x<1) print 0; x"`"; | |
109 | KWHYEAR="`/usr/bin/bc <<< "scale=3; x=$KWHDAY*365.25; if(x<1) print 0; x"`"; | |
110 | USDYEAR="`/usr/bin/bc <<< "scale=2; x=$USDDAY*365.25; if(x<1) print 0; x"`"; | |
111 | GBPYEAR="`/usr/bin/bc <<< "scale=2; x=$GBPDAY*365.25; if(x<1) print 0; x"`"; | |
112 | KWHMO="`/usr/bin/bc <<< "scale=3; x=$KWHYEAR/12; if(x<1) print 0; x"`"; | |
113 | USDMO="`/usr/bin/bc <<< "scale=2; x=$USDYEAR/12; if(x<1) print 0; x"`"; | |
114 | GBPMO="`/usr/bin/bc <<< "scale=2; x=$GBPYEAR/12; if(x<1) print 0; x"`"; | |
115 | case "$5" in | |
116 | "$CUR") | |
117 | [[ "$4" == "day" ]] && echo $GBPDAY; | |
118 | [[ "$4" == "week" ]] && echo $GBPWEEK; | |
119 | [[ "$4" == "month" ]] && echo $GBPMO; | |
120 | [[ "$4" == "year" ]] && echo $GBPYEAR; | |
121 | ;; | |
122 | "kWh") | |
123 | [[ "$4" == "day" ]] && echo $KWHDAY; | |
124 | [[ "$4" == "week" ]] && echo $KWHWEEK; | |
125 | [[ "$4" == "month" ]] && echo $KWHMO; | |
126 | [[ "$4" == "year" ]] && echo $KWHYEAR; | |
127 | ;; | |
128 | *) | |
129 | [[ "$4" == "day" ]] && echo $USDDAY; | |
130 | [[ "$4" == "week" ]] && echo $USDWEEK; | |
131 | [[ "$4" == "month" ]] && echo $USDMO; | |
132 | [[ "$4" == "year" ]] && echo $USDYEAR; | |
133 | ;; | |
134 | esac | |
135 | } | |
136 | function pad { | |
137 | out="`echo $1 | sed -e :a -e 's/^.\{1,13\}$/& /;ta'`"; | |
138 | echo "$out"; | |
139 | } | |
140 | function p { | |
141 | out="`echo $1 | sed -e :a -e 's/^.\{1,12\}$/& /;ta'`"; | |
142 | echo "$out"; | |
143 | } | |
144 | function pl { | |
145 | out="`echo $1 | sed -e :a -e 's/^.\{1,27\}$/& /;ta'`"; | |
146 | echo "$out"; | |
147 | } | |
148 | function padf { | |
149 | #Version for fiat currency, work to two decimal places | |
150 | out="`printf %.2f $(echo $1 | bc -l) | sed -e :a -e 's/^.\{1,13\}$/& /;ta'`"; | |
151 | echo "$out"; | |
152 | } | |
153 | function truncf { | |
154 | #Version for fiat currency, work to two decimal places | |
155 | out="`printf %.2f $(echo $1 | bc -l)`"; | |
156 | echo "$out"; | |
157 | } | |
158 | case $4 in | |
159 | "USD") | |
160 | LOC2USD=1; | |
161 | USD2LOC=1; | |
162 | ;; | |
163 | *) | |
164 | LOC2USD=`wget -q -O- "http://api.fixer.io/latest?base=$4&symbols=USD" | jq .rates.USD` | |
165 | USD2LOC=`wget -q -O- "http://api.fixer.io/latest?base=USD&symbols=$4" | jq .rates.$4` | |
166 | ;; | |
167 | esac | |
168 | function loc2usd { | |
169 | usd=`bc <<< "scale=8; x=$1*$LOC2USD; if(x<1) print 0; x"`; | |
170 | echo $usd; | |
171 | } | |
172 | function usd2loc { | |
173 | loc=`bc <<< "scale=8; x=$1*$USD2LOC; if(x<1) print 0; x"`; | |
174 | echo $loc; | |
175 | } | |
176 | ETH2DASH=`wget -q -O- https://shapeshift.io/marketinfo/eth_dash | jq .rate`; | |
177 | ETH2BTC=`wget -q -O- https://shapeshift.io/marketinfo/eth_btc | jq .rate`; | |
178 | ETH2XMR=`wget -q -O- https://shapeshift.io/marketinfo/eth_xmr | jq .rate`; | |
179 | function eth2alt { | |
180 | amount=$1; | |
181 | dest=$2; | |
182 | [[ "$dest" == "DASH" ]] && rate="$ETH2DASH"; | |
183 | [[ "$dest" == "BTC" ]] && rate="$ETH2BTC"; | |
184 | [[ "$dest" == "XMR" ]] && rate="$ETH2XMR"; | |
185 | alt=`bc <<< "scale=8; x=$amount*$rate; if(x<1) print 0; x"`; | |
186 | echo $alt; | |
187 | } | |
188 | address="`echo $1 | sed -e 's/0x//g'`"; | |
189 | w=$2 | |
190 | perkwh=`bc <<< "scale=8; x=$3; if(x<1) print 0; x"` | |
191 | cur=$4 | |
192 | json="`wget -q -O - http://ethermine.org/api/miner_new/$address`"; | |
193 | hashrate=`echo "$json" | jq .hashRate | sed -e s/\"//g | awk {'print $1'}`; | |
194 | hashrate0=$(bc <<< "scale=2; x=$hashrate; x"); | |
195 | avghashrate=`echo "$json" | jq .avgHashrate | sed -e s/\"//g | awk {'print $1'}`; | |
196 | avghashrate0=$(bc <<< "scale=1; x=$avghashrate/1000000; x"); | |
197 | padhashrate=$(pad $hashrate); | |
198 | #workdata="`echo "$json" | jq .rounds | grep work | egrep -o [0-9]+`" | |
199 | #x=0; | |
200 | ##echo "$workdata" | while read v; do x=$(($x + $v)); done; | |
201 | #for v in `echo $workdata`; do x=$(($x + $v)); done; | |
202 | #avghash=`bc <<< "scale=1; x=$x/100; x"`; | |
203 | epm=`echo "$json" | jq .ethPerMin`; | |
204 | bpm=`echo "$json" | jq .btcPerMin`; | |
205 | upm=`echo "$json" | jq .usdPerMin`; | |
206 | bpm=`echo "${bpm}" | sed -e 's/[eE]+*/\\*10\\^/'` | |
207 | unpaidf=`echo "$json" | jq .unpaid`; | |
208 | unpaid=$(pad `bc <<< "scale=8; x=$unpaidf/1000000000000000000; if(x<1) print 0; x"`); | |
209 | tomine=`bc <<< "scale=8; x=1-$unpaid; if(x<1) print 0; x"`; | |
210 | minstomine=`bc <<< "scale=0; x=$tomine/$epm; if(x<1) print 0; x"`; | |
211 | hourstomine=`bc <<< "scale=0; x=$minstomine/60; if(x<1) print 0; x"`; | |
212 | daystomine=`bc <<< "scale=0; x=$minstomine/60/24; x"`; | |
213 | timeframe=""; | |
214 | [[ "$daystomine" -gt "0" ]] && timeframe="$daystomine days"; | |
215 | [[ "$daystomine" -eq "0" ]] && [[ "$hourstomine" -gt "0" ]] && timeframe="$hourstomine hours"; | |
216 | [[ "$daystomine" -eq "0" ]] && [[ "$hourstomine" -eq "0" ]] && timeframe="$minstomin minutes."; | |
217 | [[ "$daystomine" -gt 0 ]] && remainderhours="`bc <<< "scale=0; x=$hourstomine-($daystomine*24); x"`" && timeframe="$timeframe, $remainderhours hours"; | |
218 | [[ "$hourstomine" -gt 0 ]] && remainder="`bc <<< "scale=0; x=$minstomine-($hourstomine*60); x"`" && timeframe="$timeframe, $remainder minutes"; | |
219 | timestampnow="`date +%s`"; | |
220 | timestampnext="`bc <<< "scale=0; x=$timestampnow+($minstomine*60); x"`"; | |
221 | timestamp="`date -d "@$timestampnext"`"; | |
222 | eph=`bc <<< "scale=2; x=$epm*60/1; if(x<1) print 0; x"`; | |
223 | epd=`bc <<< "scale=8; x=$epm*60*24/1; if(x<1) print 0; x"`; | |
224 | epw=`bc <<< "scale=8; x=$epm*60*24*7/1; if(x<1) print 0; x"`; | |
225 | epy=`bc <<< "scale=8; x=$epm*60*24*365.25/1; if(x<1) print 0; x"`; | |
226 | epmo=`bc <<< "scale=8; x=$epy/12; if(x<1) print 0; x"`; | |
227 | uph=`bc <<< "scale=2; x=$upm*60/1; if(x<1) print 0; x"`; | |
228 | upd=`bc <<< "scale=8; x=$upm*60*24/1; if(x<1) print 0; x"`; | |
229 | upw=`bc <<< "scale=8; x=$upm*60*24*7/1; if(x<1) print 0; x"`; | |
230 | upy=`bc <<< "scale=8; x=$upm*60*24*365.25/1; if(x<1) print 0; x"`; | |
231 | upmo=`bc <<< "scale=8; x=$upy/12; if(x<1) print 0; x"`; | |
232 | bph=`bc <<< "scale=2; x=$bpm*60/1; if(x<1) print 0; x"`; | |
233 | bpd=`bc <<< "scale=8; x=$bpm*60*24/1; if(x<1) print 0; x"`; | |
234 | bpw=`bc <<< "scale=8; x=$bpm*60*24*7/1; if(x<1) print 0; x"`; | |
235 | bpy=`bc <<< "scale=8; x=$bpm*60*24*365.25/1; if(x<1) print 0; x"`; | |
236 | bpmo=`bc <<< "scale=8; x=$bpy/12; if(x<1) print 0; x"`; | |
237 | cpd=$(energycosts "$watts" "$3" "$4" "day") | |
238 | cpw=$(energycosts "$watts" "$3" "$4" "week") | |
239 | cpm=$(energycosts "$watts" "$3" "$4" "month") | |
240 | cpy=$(energycosts "$watts" "$3" "$4" "year") | |
241 | lcpd=$(energycosts "$watts" "$3" "$4" "day" "$4") | |
242 | lcpw=$(energycosts "$watts" "$3" "$4" "week" "$4") | |
243 | lcpm=$(energycosts "$watts" "$3" "$4" "month" "$4") | |
244 | lcpy=$(energycosts "$watts" "$3" "$4" "year" "$4") | |
245 | wpd=$(energycosts "$watts" "$3" "$4" "day" "kWh") | |
246 | wpw=$(energycosts "$watts" "$3" "$4" "week" "kWh") | |
247 | wpm=$(energycosts "$watts" "$3" "$4" "month" "kWh") | |
248 | wpy=$(energycosts "$watts" "$3" "$4" "year" "kWh") | |
249 | pct=$(truncf `bc <<< "scale=5; x=(($cpy/$upy)*100); x"`); | |
250 | keep=$(truncf `bc <<< "scale=5; x=(100-$pct); x"`); | |
251 | wpmhs=$(truncf `bc <<< "scale=5; x=($watts/$avghashrate0); x"`); | |
252 | nepd=`bc <<< "scale=8; x=$epd*($keep/100); if(x<1) print 0; x"`; | |
253 | nepw=`bc <<< "scale=8; x=$epw*($keep/100); if(x<1) print 0; x"`; | |
254 | nepy=`bc <<< "scale=8; x=$epy*($keep/100); if(x<1) print 0; x"`; | |
255 | nepmo=`bc <<< "scale=8; x=$epmo*($keep/100); if(x<1) print 0; x"`; | |
256 | nbpd=`bc <<< "scale=8; x=$bpd*($keep/100); if(x<1) print 0; x"`; | |
257 | nbpw=`bc <<< "scale=8; x=$bpw*($keep/100); if(x<1) print 0; x"`; | |
258 | nbpy=`bc <<< "scale=8; x=$bpy*($keep/100); if(x<1) print 0; x"`; | |
259 | nbpmo=`bc <<< "scale=8; x=$bpmo*($keep/100); if(x<1) print 0; x"`; | |
260 | lineodash | |
261 | echo "Hash rate and power consumption" | |
262 | lineodash | |
263 | echo "" | |
264 | echo "Hashrate: $(pad $avghashrate0) $(p MH/sec) (average hash rate over the last 24 hours)" | |
265 | echo " $(pad $hashrate0) $(p MH/sec) (current hash rate over the last few minutes)" | |
266 | echo "" | |
267 | echo "Electricity: $(pl "$watts watts continuous load")" | |
268 | echo " $(pl "$wpmhs watts per MH/sec")" | |
269 | echo " $(pl "Power costs $pct% of output") (calculated from USD power cost as percentage of USD returns)" | |
270 | echo "" | |
271 | echo "Unpaid: $(pad $unpaid) $(p ETH) (amount accumulated at the pool towards next payout)"; | |
272 | echo "" | |
273 | echo "Next Ether in: $(pl "$timeframe") (estimate: $timestamp)"; | |
274 | #echo " at: $timestamp"; | |
275 | echo "" | |
276 | lineodash | |
277 | echo "Estimated rewards" | |
278 | lineodash | |
279 | echo "" | |
280 | echo "Output (ETH): $(pad $epd) $(p ETH/day) (net: $nepd ETH/day after power cost)" | |
281 | echo " $(pad $epw) $(p ETH/week) (net: $nepw ETH/week)" | |
282 | echo " $(pad $epmo) $(p ETH/month) (net: $nepmo ETH/month)" | |
283 | echo " $(pad $epy) $(p ETH/year) (net: $nepy ETH/year)" | |
284 | echo "Output (BTC): $(pad $bpd) $(p BTC/day) (net: $nbpd BTC/day)" | |
285 | echo " $(pad $bpw) $(p BTC/week) (net: $nbpw BTC/week)" | |
286 | echo " $(pad $bpmo) $(p BTC/month) (net: $nbpmo BTC/month)" | |
287 | echo " $(pad $bpy) $(p BTC/year) (net: $nbpy BTC/year)" | |
288 | echo "Exchange (DASH): $(pad $(eth2alt $epd DASH)) $(p DASH/day) (net: $(eth2alt $nepd DASH) DASH/day @ $ETH2DASH DASH/ETH; exchange rate: shapeshift.io)" | |
289 | echo " $(pad $(eth2alt $epw DASH)) $(p DASH/week) (net: $(eth2alt $nepw DASH) DASH/week)" | |
290 | echo " $(pad $(eth2alt $epmo DASH)) $(p DASH/month) (net: $(eth2alt $nepmo DASH) DASH/month)" | |
291 | echo " $(pad $(eth2alt $epy DASH)) $(p DASH/year) (net: $(eth2alt $nepy DASH) DASH/year)" | |
292 | echo "Exchange (XMR): $(pad $(eth2alt $epd XMR)) $(p XMR/day) (net: $(eth2alt $nepd XMR) XMR/day @ $ETH2XMR XMR/ETH; exchange rate: shapeshift.io)" | |
293 | echo " $(pad $(eth2alt $epw XMR)) $(p XMR/week) (net: $(eth2alt $nepw XMR) XMR/week)" | |
294 | echo " $(pad $(eth2alt $epmo XMR)) $(p XMR/month) (net: $(eth2alt $nepmo XMR) XMR/month)" | |
295 | echo " $(pad $(eth2alt $epy XMR)) $(p XMR/year) (net: $(eth2alt $nepy XMR) XMR/year)" | |
296 | echo "Exchange (BTC): $(pad $(eth2alt $epd BTC)) $(p BTC/day) (net: $(eth2alt $nepd BTC) BTC/day @ $ETH2BTC BTC/ETH; exchange rate: shapeshift.io)" | |
297 | echo " $(pad $(eth2alt $epw BTC)) $(p BTC/week) (net: $(eth2alt $nepw BTC) BTC/week)" | |
298 | echo " $(pad $(eth2alt $epmo BTC)) $(p BTC/month) (net: $(eth2alt $nepmo BTC) BTC/month)" | |
299 | echo " $(pad $(eth2alt $epy BTC)) $(p BTC/year) (net: $(eth2alt $nepy BTC) BTC/year)" | |
300 | case $4 in | |
301 | "USD") | |
302 | echo "Output (USD): $(padf $upd) $(p USD/day) (estimated from current performance, with data & exchange rates supplied by the pool)" | |
303 | echo " $(padf $upw) USD/week" | |
304 | echo " $(padf $upmo) USD/month" | |
305 | echo " $(padf $upy) USD/year" | |
306 | ;; | |
307 | *) | |
308 | echo "Exchange ($4): $(padf $(usd2loc $upd)) $(p $4/day) (converted from $(truncf "scale=2; $upd"|bc) USD @ $(usd2loc 1) USD/$4; exchange rate: fixer.io)" | |
309 | echo " $(padf $(usd2loc $upw)) $(p $4/week) (converted from $(truncf "scale=2; $upw"|bc) USD @ $(usd2loc 1) USD/$4)" | |
310 | echo " $(padf $(usd2loc $upmo)) $(p $4/month) (converted from $(truncf "scale=2; $upmo"|bc) USD @ $(usd2loc 1) USD/$4)" | |
311 | echo " $(padf $(usd2loc $upy)) $(p $4/year) (converted from $(truncf "scale=2; $upy"|bc) USD @ $(usd2loc 1) USD/$4)" | |
312 | ;; | |
313 | esac | |
314 | #echo "Power (kWh): $(padf $wpd) kWh/day" | |
315 | #echo " $(padf $wpw) kWh/week" | |
316 | #echo " $(padf $wpm) kWh/month" | |
317 | #echo " $(padf $wpy) kWh/year" | |
318 | case $4 in | |
319 | "USD") | |
320 | echo "Power (USD): $(padf $cpd) $(p USD/day) ($wpd kWh/day @ $perkwh $4/kWh)" | |
321 | echo " $(padf $cpw) $(p USD/week) ($wpw kWh/week @ $perkwh $4/kWh)" | |
322 | echo " $(padf $cpm) $(p USD/month) ($wpm kWh/month @ $perkwh $4/kWh)" | |
323 | echo " $(padf $cpy) $(p USD/year) ($wpy kWh/year @ $perkwh $4/kWh)" | |
324 | ;; | |
325 | *) | |
326 | echo "Power ($4): $(padf $lcpd) $(p $4/day) ($wpd kWh/day @ $perkwh$4/kWh = $cpd USD/day @ $(loc2usd 1) $4/USD = $(loc2usd $perkwh) USD/kWh)" | |
327 | echo " $(padf $lcpw) $(p $4/week) ($wpw kWh/week @ $perkwh$4/kWh = $cpw USD/week" | |
328 | echo " $(padf $lcpm) $(p $4/month) ($wpm kWh/month @ $perkwh$4/kWh = $cpm USD/month" | |
329 | echo " $(padf $lcpy) $(p $4/year) ($wpy kWh/year @ $perkwh$4/kWh = $cpy USD/year" | |
330 | ;; | |
331 | esac | |
332 | lineodash | |
333 | case $4 in | |
334 | "USD") | |
335 | echo "Net (USD): $(padf `echo "scale=2; $upd-$cpd"|bc`) USD/day"; | |
336 | echo " $(padf `echo "scale=2; $upw-$cpw"|bc`) USD/week"; | |
337 | echo " $(padf `echo "scale=2; $upmo-$cpm"|bc`) USD/month"; | |
338 | echo " $(padf `echo "scale=2; $upy-$cpy"|bc`) USD/year"; | |
339 | ;; | |
340 | *) | |
341 | echo "Net ($4): $(padf `echo "scale=2; ($upd-$cpd)*$USD2LOC"|bc`) $(p $4/day) (converted from $(truncf "scale=2; $upd-$cpd"|bc) USD @ $(usd2loc 1) USD/$4; exchange rate: fixer.io)"; | |
342 | echo " $(padf `echo "scale=2; ($upw-$cpw)*$USD2LOC"|bc`) $(p $4/week) (converted from $(truncf "scale=2; $upw-$cpw"|bc) USD @ $(usd2loc 1) USD/$4)"; | |
343 | echo " $(padf `echo "scale=2; ($upmo-$cpm)*$USD2LOC"|bc`) $(p $4/month) (converted from $(truncf "scale=2; $upmo-$cpm"|bc) USD @ $(usd2loc 1) USD/$4)"; | |
344 | echo " $(padf `echo "scale=2; ($upy-$cpy)*$USD2LOC"|bc`) $(p $4/year) (converted from $(truncf "scale=2; $upy-$cpy"|bc) USD @ $(usd2loc 1) USD/$4)"; | |
345 | ;; | |
346 | esac | |
347 | lineodash | |
348 | echo "" | |
349 | echo "Useful? Feel free to leave me a tip. ETH: 0x58f7F4d641dc32A4a1349aad866F132C6794659e / BTC: 155D6ZLLUezX6c8k6CXTUgF55qDP1P2Uz4 - Thanks!" |