Created
February 3, 2015 23:35
-
-
Save sgade/addffb9fbd340af0e7d5 to your computer and use it in GitHub Desktop.
Downlink/Uplink graph
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
/* | |
* A very fast and quick download/upload graph for your fritz.box. | |
* This is not optimized. | |
* | |
* Dependencies: | |
* - andrewjstone/cli-chart @ ~0.3.1 | |
* - sgade/router-upnp @ ~0.2.0 | |
* | |
* */ | |
var Chart = require('cli-chart'); | |
var FritzBoxUPNP = require('router-upnp').FritzBoxUPNP; | |
var box = null; | |
var chart = new Chart({ | |
xlabel: 'time', | |
ylabel: 'byte/s', | |
direction: 'y', | |
width: 80, | |
height: 10, | |
step: 1 | |
}); | |
function pollAndDraw() { | |
box.getByteReceiveRate(function(err, rate) { | |
if ( !!err ) { | |
throw err; | |
} | |
chart.addBar(rate, 'blue'); | |
box.getByteSendRate(function(err, rate) { | |
if ( !!err ) { | |
throw err; | |
} | |
chart.addBar(rate, 'green'); | |
chart.draw(); | |
setTimeout(pollAndDraw, 1000); | |
}); | |
}) | |
} | |
function main() { | |
box = new FritzBoxUPNP(); | |
box.serviceDiscovery(function(err) { | |
if ( !!err ) { | |
throw err; | |
} | |
pollAndDraw(); | |
}); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment