sensu-plugins / sensu-plugins-docker

This plugin provides native Docker instrumentation for monitoring and metrics collection, including: container status, container number, and container metrics via `docker ps`.
http://sensu-plugins.io
MIT License
35 stars 57 forks source link

Adding cpu percentage calculation in metrics-docker-stats.rb #56

Closed alcasim closed 7 years ago

alcasim commented 7 years ago

Pull Request Checklist

Is this in reference to an existing issue?

General

New Plugins

Purpose

Calculating percentage of CPU Usage based on metrics from Docker API it's tough and most of times not possible, as involves some operations which are not always supported (like InfluxDB, it's not posible to count number of metrics to be used as part of an arithmetical operation). I'm adding this metric to metrics-docker-stats.rb with a config flag so accessing to this metric will be much easier.

An example of the output in this gist: https://gist.github.com/alcasim/b385f178e1af5879760f9d28a62bc8a6

Known Compatibility Issues

majormoses commented 7 years ago

If you can give me a good reason I am all ears.

alcasim commented 7 years ago

Hi @majormoses sorry for the late reply. I agree than not controlling the number of decimals in the output it's a mistake, there is no reason why that accuracy is needed as you pointed out. I have updated this PR and the gist with the new output.

majormoses commented 7 years ago

Sorry this fell off my radar, I will review and will get to it shortly. Hoping to merge and release today assuming no other issues.

majormoses commented 7 years ago

released: https://rubygems.org/gems/sensu-plugins-docker/versions/1.5.0