Created
January 13, 2017 11:26
-
-
Save you21979/5fc1b0f326bc03a9bb0cde9dc444004f to your computer and use it in GitHub Desktop.
This file contains 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
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