Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #28 from signalfx/python2.6-fix
Browse files Browse the repository at this point in the history
Correct readme and make plugin 2.6 compatible
  • Loading branch information
molner authored Sep 19, 2017
2 parents b3bda18 + fddeb29 commit 724cee2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<Rule "Cpu">
<Rule "CpuShares">
<Match "regex">
Type "^cpu$"
Type "^cpu.shares$"
</Match>
Target "return"
</Rule>
<Rule "CpuQuota">
<Match "regex">
Type "^cpu.quota$"
</Match>
Target "return"
</Rule>
<Rule "CpuThrottlingData">
<Match "regex">
Type "^cpu.throttling_data$"
Expand Down
9 changes: 8 additions & 1 deletion dockerplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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.
Expand Down

0 comments on commit 724cee2

Please sign in to comment.