View on GitHub

swisspush

Community Contributions by Developers in the Swiss Postal IT

28 January 2016 - Laurent Bovet

turtle-race

There are plenty of Node modules related to Docker. One is docker-stats which provides a continuous stream of container statistics.

Combining it with turtle-race is an easy way to quickly monitor such statistics as graphs in the terminal.

For example, the following script would monitor the cpu usage of all containers currently running.

var stats = require('docker-stats');
var through = require('through2');
var turtle = (require('turtle-race'))();
stats({statsinterval: 1}).pipe(through.obj(function(container, enc, cb) {
  turtle.metric(container.name, "cpu")
    .push(container.stats.cpu_stats.cpu_usage.cpu_percent);
  return cb();
}));

Of course, this can be combined with many other ways to collect metrics, e.g. to output the graphs shown above.


blog comments powered by Disqus