Last active
December 20, 2015 07:49
-
-
Save jsocol/6095941 to your computer and use it in GitHub Desktop.
Simple Django management command to ping graphite on deploy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import time | |
| from django.conf import settings | |
| from django.core.management.base import NoArgsCommand | |
| class Command(NoArgsCommand): | |
| help = 'Notify stats on deploy.' | |
| def handle(self, **options): | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.connect((socket.gethostbyname(settings.STATSD_HOST), | |
| settings.GRAPHITE_PORT)) | |
| fmt = '%s.deploy 1 %d\n' | |
| data = fmt % (settings.STATSD_PREFIX, int(time.time())) | |
| s.send(data) | |
| s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment