Created
November 6, 2010 18:44
-
-
Save Voker57/665603 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Bitcoin (฿) daemon monitor | |
-- %bitcoin_speed - current speed in khash/s | |
-- %bitcoin_balance - current balance | |
-- by Voker57 <[email protected]> | |
-- 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