Permalink
Browse files

Added support for gmetric units

  • Loading branch information...
codeinthehole committed Jun 24, 2012
1 parent 5d0190f commit df3368388d797e271715a681d098c188bc433575
Showing with 8 additions and 3 deletions.
  1. +6 −1 pygmetric/rabbitmq.py
  2. +2 −2 pygmetric/shell.py
View
@@ -3,14 +3,18 @@
def submit(vhost, queue, debug):
stats = fetch_stats(vhost, queue)
- for metric in stats:
+ for metric in stats.values():
call_gmetric(name=metric['name'],
value=metric['value'],
type=metric['type'],
+ units=metric['units'],
debug=debug)
def fetch_stats(vhost, queue):
+ """
+ Fetch the count of a given queue
+ """
cmd = 'rabbitmqctl list_queues -p %s' % vhost
stdout = run(cmd)
lines = stdout.split("\n")
@@ -26,5 +30,6 @@ def fetch_stats(vhost, queue):
'name': name,
'value': int(count),
'type': 'uint32',
+ 'units': 'Queue size',
}
return metrics
View
@@ -13,11 +13,11 @@ def run(cmd):
return stdout
-def call_gmetric(name, value, type='float', debug=False):
+def call_gmetric(name, value, type='float', units="", debug=False):
"""
Submit a metric
"""
- cmd = 'gmetric --type %s --name %s --value %s' % (type, name, value)
+ cmd = 'gmetric --type %s --name %s --value %s --units=%s' % (type, name, value, units)
if debug:
print cmd
else:

0 comments on commit df33683

Please sign in to comment.