Skip to content

Instantly share code, notes, and snippets.

@alq666
alq666 / instance.py
Created September 8, 2013 02:49
Compute the count of instances per zone
import simplejson as json
import sys
#{
# "results": 91,
# "rows": [
# {
# "ec2": {
# "instance_action": "none",
# "instance_id": "i-f9069c96",
@alq666
alq666 / sobolc.awk
Last active December 23, 2015 05:09
BEGIN {
print "ts,payloads,points,read,transform,kafka,redis"
}
# 2013-09-16 02:30:04,537 INFO dd.sobotka.core (core.py:186) - sobotka_loop: 429.2ms - processed 3 payloads (0.0/ms) 237 points (0.6/ms) - read:0.0ms, transform:56.7ms, kafka_write:39.7ms redis_write:294.8ms
/redis_write/ {
ts = $1 "T" $2
match($0, /processed ([[:digit:]]+) payloads.*([[:digit:]]+) points.*- read:[[:digit:].]+)ms, transform:([[:digit:].]+)ms, kafka_write:([[:digit:].]+)ms redis_write:([[:digit:].]+)ms/, arr);
print substr(ts, 1, length(ts) - 4), arr[1], arr[2], arr[3], arr[4], arr[5], arr[6];
}
@alq666
alq666 / statsd.md
Created September 27, 2013 03:06
statsD protocol sample
@alq666
alq666 / common-role.rb
Last active December 24, 2015 03:29
An example of datadog's chef recipe for nginx
default_overrides({
:datadog => {
:api_key => "...",
# ...
}
})

The Challenge

  1. Sign up for Datadog, get the agent reporting metrics from your local machine. Bonus question- what is the agent?

  2. Submit an event via the API.

  3. Get an event to appear in your email inbox (the email address you signed up for the account with)

{% set pkgrepo = {
'Debian': {
"managed": True,
"humanname": "Datadog Agent",
"name": "deb http://apt.datadoghq.com/ unstable main",
"keyserver": "keyserver.ubuntu.com",
"keyid": "C7A7DA52",
"file": "/etc/apt/sources.list.d/datadog.list"
},
'RedHat': {
@alq666
alq666 / .toprc
Created October 22, 2013 22:23
Top configuration
RCfile for "top with windows" # shameless braggin'
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=3.000, Curwin=0
Def fieldscur=AEHIOQTWKNMbcdfgjplrsuvyzX
winflags=64441, sortindx=10, maxtasks=0
summclr=1, msgsclr=1, headclr=3, taskclr=1
Job fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
winflags=62777, sortindx=0, maxtasks=0
summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
winflags=62777, sortindx=13, maxtasks=0
@alq666
alq666 / README.md
Created October 26, 2013 02:10 — forked from alekstorm/README.md

Installation

To install, place datadog.py in your callback plugins directory. If you don't yet have one, run:

mkdir -p plugins/callback

Then place the following in your ansible.cfg file:

[defaults]

callback_plugins = ./plugins/callback

@alq666
alq666 / little.json
Created October 31, 2013 03:37
Illustrating Little's law with ELB statistics in Datadog
{
"events": [],
"requests": [
{
"q": "aws.elb.latency{host:elb_name}*sum:aws.elb.request_count{host:elb_name}"
}
],
"viz": "timeseries"
}
@alq666
alq666 / pg-df.sql
Created November 16, 2013 18:11
Compute relation sizes
SELECT nspname,
relname,
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N
ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 40;