diff --git a/README.md b/README.md index 529f4fe..da219d3 100644 --- a/README.md +++ b/README.md @@ -218,12 +218,18 @@ For convenience, you'll find those configuration blocks in the example configura If a filter has been configured, then additional resource allocation metrics can be gathered by adding the following snippet to the plugin's filter configuration. ```apache - + - Type "^cpu$" + Type "^cpu.shares$" Target "return" + + + Type "^cpu.quota$" + +Target "return" + Type "^cpu.throttling_data$" diff --git a/dockerplugin.py b/dockerplugin.py index 722ed6f..4cae2e2 100755 --- a/dockerplugin.py +++ b/dockerplugin.py @@ -287,7 +287,7 @@ def read_cpu_quota_stats(container, container_inspect, cstats): stats['read'][:-4], "%Y-%m-%dT%H:%M:%S.%f") # Time delta in ms between two reads from stats endpoint - delta_between_reads = (read - preread).total_seconds() * 1000 + delta_between_reads = total_milliseconds((read - preread)) cpu_total = stats['cpu_stats']['cpu_usage']['total_usage'] precpu_stats = stats['precpu_stats'] precpu_total = precpu_stats['cpu_usage']['total_usage'] @@ -303,6 +303,13 @@ def read_cpu_quota_stats(container, container_inspect, cstats): type_instance='used.percent', t=stats['read']) +# total_seconds() method of datetime available only from python 2.7 +def total_milliseconds(td): + td_microseconds = td.microseconds + \ + ((td.seconds + td.days * 24 * 3600) * 10**6) + td_milliseconds = td_microseconds / float(10**3) + return td_milliseconds + class DimensionsProvider: """Helper class for performing dimension extraction from a given container.