Skip to content

Commit

Permalink
Added support for labels
Browse files Browse the repository at this point in the history
  • Loading branch information
jamtur01 committed Mar 22, 2016
1 parent c4828ee commit 99a7fa3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dockerplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@ def _c(c):
return '{id}/{name}'.format(id=c['Id'][:7], name=c['Name'])


def _d(d):
"""Formats a dictionary of key/value pairs as a comma-delimited list of
key=value tokens."""
return ','.join(['='.join(p) for p in d.items()])


class Stats:
@classmethod
def emit(cls, container, type, value, t=None, type_instance=None):
val = collectd.Values()
val.plugin = 'docker'
val.plugin_instance = container['Name']

if container['Labels']:
val.plugin_instance += '[{labels}]'.format(
labels=_d(container['Labels']))

if type:
val.type = type
if type_instance:
Expand Down

0 comments on commit 99a7fa3

Please sign in to comment.