Skip to content

Commit

Permalink
Add Hostname dimension.
Browse files Browse the repository at this point in the history
  • Loading branch information
linshu committed May 31, 2017
1 parent a8d6246 commit 6f99f7e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/cloudwatch/modules/dimensionhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def __init__(self, config_helper, vl):
self.vl = vl
self.dimension_handlers["InstanceId"] = Dimension_InstanceId(self.config, self.vl)
self.dimension_handlers["PluginInstance"] = Dimension_PluginInstance(self.config, self.vl)
self.dimension_handlers["Hostname"] = Dimension_Hostname(self.config, self.vl)
for h in self.dimension_handlers:
self.dimension_handlers[h].register_plugin()

Expand Down
30 changes: 24 additions & 6 deletions src/cloudwatch/modules/dimensionplugins/generic_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
This is the file containing generic dimension plugin classes
"""

import os
from . import DimensionPlugin

def dimension_get_instance_id(dimension, args):
dimension[args['name']] = args['value']

"""
This InstanceId Dimension coming from configured host instance
"""

def dimension_get_instance_id(dimension, args):
dimension[args['name']] = args['value']

class Dimension_InstanceId(DimensionPlugin):
def register_plugin(self):
self.func = dimension_get_instance_id
Expand All @@ -19,12 +21,13 @@ def register_plugin(self):
}


def dimension_get_plugin_instance(dimension, args):
dimension[args['name']] = args['value']

"""
This PluginInstance Dimension coming from collectd value plugin instance
"""

def dimension_get_plugin_instance(dimension, args):
dimension[args['name']] = args['value']

class Dimension_PluginInstance(DimensionPlugin):
def register_plugin(self):
self.func = dimension_get_plugin_instance
Expand All @@ -33,3 +36,18 @@ def register_plugin(self):
'value': self.vl.plugin_instance
}


"""
Hostname Dimension report the hostname value
"""

def dimension_get_hostname(dimension, args):
dimension[args['name']] = args['value']

class Dimension_Hostname(DimensionPlugin):
def register_plugin(self):
self.func = dimension_get_hostname
self.args = {
'name': "Hostname",
'value': os.uname()[1]
}

0 comments on commit 6f99f7e

Please sign in to comment.