Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added support for gmetric units

  • Loading branch information...
commit df3368388d797e271715a681d098c188bc433575 1 parent 5d0190f
@codeinthehole authored
Showing with 8 additions and 3 deletions.
  1. +6 −1 pygmetric/rabbitmq.py
  2. +2 −2 pygmetric/shell.py
View
7 pygmetric/rabbitmq.py
@@ -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
4 pygmetric/shell.py
@@ -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:
Please sign in to comment.
Something went wrong with that request. Please try again.