Skip to content

Instantly share code, notes, and snippets.

@Voker57
Created November 6, 2010 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Voker57/665603 to your computer and use it in GitHub Desktop.
Save Voker57/665603 to your computer and use it in GitHub Desktop.
-- 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