Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for labels #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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