Skip to content

Instantly share code, notes, and snippets.

@you21979
Created January 13, 2017 11:26
Show Gist options
  • Save you21979/5fc1b0f326bc03a9bb0cde9dc444004f to your computer and use it in GitHub Desktop.
Save you21979/5fc1b0f326bc03a9bb0cde9dc444004f to your computer and use it in GitHub Desktop.
const fees = require('bitcoinfees-21co');
const task = require('promise-util-task');
const munin = require('munin-plugin');
const api = fees.FeesApi;
const graphRecommended = (res) => {
const g = new munin.Graph('bitcoin feerate','satoshi/byte','bitcoin');
Object.keys(res).forEach(key => {
g.add(new munin.Model.Default(key).setValue(res[key]));
})
g.sortLabel();
return g
}
const graphList = (res) => {
const data = res.reduce((r,v) => {
return r + v.memCount
}, 0)
const g = new munin.Graph('bitcoin mempool','transactions','bitcoin');
g.add(new munin.Model.Default("mempool").setValue(data));
return g
}
const process = () =>
task.seq([
() => api.recommended().then(res => graphRecommended(res)),
() => api.list().then(res => graphList(res.fees))
]).then(list => munin.create(list) )
const main = () => process()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment