Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- Bitcoin (฿) daemon monitor
-- %bitcoin_speed - current speed in khash/s
-- %bitcoin_balance - current balance
-- by Voker57 <voker57@gmail.com>
-- Public domain
local defaults={
update_interval=30 * 1000
}
local settings=table.join(statusd.get_config("bitcoin"), defaults)
local bitcoin_timer
local function get_bitcoin_speed()
local hps = io.popen("bitcoind gethashespersec")
r = hps:read()
return string.format("%0.2f", r / 1000)
end
local function get_bitcoin_balance()
local bl = io.popen("bitcoind getbalance")
r = bl:read()
return string.format("%0.2f", r)
end
local function update_bitcoin()
local bitcoin_speed = get_bitcoin_speed()
local bitcoin_balance = get_bitcoin_balance()
statusd.inform("bitcoin_balance", bitcoin_balance)
statusd.inform("bitcoin_speed", bitcoin_speed)
bitcoin_timer:set(settings.update_interval, update_bitcoin)
end
-- Init
bitcoin_timer=statusd.create_timer()
update_bitcoin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.