1 -- Authors: Voker57 <voker57@gmail.com>
2 -- License: Public domain
3 -- Last Changed: Unknown
5 -- Bitcoin (฿) daemon monitor
7 -- %bitcoin_speed - current speed in khash/s
8 -- %bitcoin_balance - current balance
10 -- by Voker57 <voker57@gmail.com>
14 update_interval
=30 * 1000
17 local settings
=table.join(statusd
.get_config("bitcoin"), defaults
)
21 local function get_bitcoin_speed()
22 local hps
= io
.popen("bitcoind gethashespersec 2>/dev/null")
26 local answ
= hps
:read("*a")
27 if not answ
or answ
== "" then
30 return string.format("%0.2f", answ
/ 1000)
33 local function get_bitcoin_balance()
34 local bl
= io
.popen("bitcoind getbalance 2>/dev/null")
38 local answ
= bl
:read("*a")
39 if not answ
or answ
== "" then
42 return string.format("%0.2f", answ
)
45 local function update_bitcoin()
46 local bitcoin_speed
= get_bitcoin_speed()
47 local bitcoin_balance
= get_bitcoin_balance()
48 statusd
.inform("bitcoin_balance", bitcoin_balance
)
49 statusd
.inform("bitcoin_speed", bitcoin_speed
)
50 bitcoin_timer
:set(settings
.update_interval
, update_bitcoin
)
54 bitcoin_timer
=statusd
.create_timer()