2013-04-23 18:51:17 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2013-04-18 22:58:19 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2015-08-21 02:10:41 +02:00
|
|
|
help = """Send some stats to statsd."""
|
2013-04-18 22:58:19 +02:00
|
|
|
|
2015-08-21 02:10:41 +02:00
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument('operation', metavar='<operation>', type=str,
|
|
|
|
choices=['incr', 'decr', 'timing', 'timer', 'gauge'],
|
|
|
|
help="incr|decr|timing|timer|gauge")
|
|
|
|
parser.add_argument('name', metavar='<name>', type=str)
|
|
|
|
parser.add_argument('val', metavar='<val>', type=str)
|
2013-04-18 22:58:19 +02:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2015-08-21 02:10:41 +02:00
|
|
|
operation = options['operation']
|
|
|
|
name = options['name']
|
|
|
|
val = options['val']
|
2013-04-18 22:58:19 +02:00
|
|
|
|
|
|
|
if settings.USING_STATSD:
|
|
|
|
from statsd import statsd
|
|
|
|
|
|
|
|
func = getattr(statsd, operation)
|
|
|
|
func(name, val)
|