Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
"""Copyright 2008 Orbitz WorldWide
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@alq666
alq666 / carbon-relay.md
Created July 31, 2012 18:45
Setting up carbon-relay

For ubuntu:

Install graphite

sudo add-apt-repository ppa:muffinresearch/graphite
sudo apt-get update
sudo apt-get install python-graphite

Create /etc/carbon/relay-rules.conf

@alq666
alq666 / ddagent.py.diff
Created August 6, 2012 19:36
Fixes invalid port type
diff --git a/ddagent.py b/ddagent.py
index fb3f50d..79ac59d 100755
--- a/ddagent.py
+++ b/ddagent.py
@@ -182,7 +182,7 @@ class ApiInputHandler(tornado.web.RequestHandler):
class Application(tornado.web.Application):
def __init__(self, port, agentConfig):
- self._port = port
+ self._port = int(port)
@alq666
alq666 / pong.py
Created August 7, 2012 17:38
Testing pup
# easy_install dogstatsd-python
import time
from statsd import statsd
while True:
statsd.increment("ping.pong")
time.sleep(0.5)
@alq666
alq666 / iostat.py
Created August 7, 2012 23:12
iostat.py
from statsd import statsd
import sys
device = sys.argv[1]
while True:
a = sys.stdin.readline().strip()
data = a.split()
if len(data) == 3:
try:
@alq666
alq666 / fabric-test.sh
Created August 10, 2012 21:36
Testing the fabric integration
easy_install fabric
python -c "import fabric; print fabric"
# <module 'fabric' from '.../python2.7/site-packages/Fabric-1.4.3-py2.7.egg/fabric/__init__.pyc'>
cd dogapi
fab -f examples/fabfile.py sweet_task:"yay!"
# My sweet task always runs properly.
#
# Done.
# standard imports for this example
import os
import time
from datetime import datetime as dt
from datetime import timedelta as delta
import math
# import the simple dog client
from dogapi import dog_http_api as dog
@alq666
alq666 / hostname.py
Created August 17, 2012 18:04
Determine how hosts are set
# on one triplet, e.g. s11.ams, s11.aus, s11.chi
# python hostname.py
import socket
import os
import pprint
print("socket, hostname")
print(socket.gethostname(), os.popen("hostname").read().strip(), [r for r in open("/etc/dd-agent/datadog.conf").readlines() if r.find("hostname:") > -1])
pprint.pprint(open("/etc/hosts").readlines())
@alq666
alq666 / *magit-diff*.txt
Created August 17, 2012 21:30
Fix for #157
Changes in HEAD
Modified checks/common.py
diff --git a/checks/common.py b/checks/common.py
index 1b84928..b014f63 100644
--- a/checks/common.py
+++ b/checks/common.py
@@ -126,11 +126,12 @@ class checks(object):
if self.agentConfig.get('hostname'):
metadata['agent-hostname'] = self.agentConfig.get('hostname')
@alq666
alq666 / gist:3519070
Created August 29, 2012 21:14
nginx status configuration
location = /nginx_status {
listen 9999;
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}