Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
"""
Nagios plugin to check PostgreSQL 9 streaming replication lag.
Requires psycopg2 and nagiosplugin (both installable with pip/easy_install).
MIT licensed:
Copyright (c) 2010 Jacob Kaplan-Moss. All rights reserved.
Creating log file /Users/alq/.datadog-agent/ddagent-install.log.....Done
Operating System: Darwin
Setting up virtual environment..... % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 26 112k 26 30857 0 0 155k 0 --:--:-- --:--:-- --:--:-- 155k 100 112k 100 112k 0 0 441k 0 --:--:-- --:--:-- --:--:-- 440k
New python executable in /Users/alq/.datadog-agent/venv/bin/python
Installing setuptools...............................done.
Installing pip.....................done.
Done
Installing tornado 2.4.1 using pip.....Wheel installs require setuptools >= 0.8 for dist-info support.
@alq666
alq666 / dog.r
Created January 17, 2014 04:14
Query Datadog from R
query_to_df <- function(api_key, application_key, query, from_t, to_t) {
res <- getForm('https://app.datadoghq.com/api/v1/query', api_key=api_key, application_key=application_key, from=from_t, to=to_t, query=query)
parsed <- fromJSON(res)
series <- parsed[['series']]
timeseries <- series[[1]]
pointlist <- timeseries[['pointlist']]
timestamps <- to_epoch(sapply(pointlist, '[', 1))
values <- sapply(pointlist, '[', 2)
return(data.frame(timestamps, values))
}

my comments in bold

@datadoghq - Overall well done! Here's some feedback:

Signup/User process

  • when someone invites you to their datadog/team, you get an email but because you are already registered you can't join their team. Especially annoying for freelancers that work for multiple customers but don't have an email account at the customer site
  • disable a user is scary (will this delete it, can I re-create it?); a warning or ? next to it would help for fast understanding
  • if the user you invite does not have it's gmail activated yet (google for apps), when the email is added it's send out (but doesn't reach it of course). There is no way of re-sending the invite from the admin side
  • the forcing of registering at least one agent/integration is really annoying. if you signup through an ipad or the person signing up (like billing) does not have any way to go past that screen. So you wonder , am I registered or not? In our case the person installed the mac agent from it's laptop to get it going. N
@alq666
alq666 / markers.json
Created March 5, 2014 16:25
Example of markers
{
"events": [],
"requests": [
{
"q": "avg:system.load.norm.1{blah} by {host}",
"stacked": false
},
{
"q": "avg:system.load.norm.1{blah} by {host}",
"stacked": false
{
"board_bgtype": "board_graph",
"board_title": "Elasticsearch Screenboard",
"height": 160,
"id": 3,
"template_variables": [
{
"default": "*",
"name": "scope"
}
@alq666
alq666 / gist:9927492
Last active August 29, 2015 13:58
Top function summary
Shortcut num_series (= N) method asc / desc
----------------------------------------------------------
topN 5, 10, 15, 20 mean desc
topN_max 5, 10, 15, 20 max desc
topN_min 5, 10, 15, 20 min desc
topN_last 5, 10, 15, 20 last desc
topN_area 5, 10, 15, 20 area desc
topN_norm 5, 10, 15, 20 norm desc
bottomN 5, 10, 15, 20 mean asc
bottomN_max 5, 10, 15, 20 max asc
{
"board_bgtype": "board_graph",
"board_title": "High-level Screenboard with Datadog",
"height": 143,
"id": 2938,
"template_variables": [
{
"default": "*",
"name": "scope"
}
@alq666
alq666 / dog-splunk.sh
Created May 2, 2014 19:32
Datadog & Splunk minimal integration
#!/bin/bash
source /Users/alq/Code/workspace/bin/activate
dog event post "Found $SPLUNK_ARG_1 events in splunk" "Matching $SPLUNK_ARG_2 based on $SPLUNK_ARG_5:, from report $SPLUNK_ARG_4. More details at $SPLUNK_ARG_6."
@alq666
alq666 / ck.awk
Created August 28, 2014 21:08
Parse PG checkpoint log entries
BEGIN {
print "tstamp,buffers,pct_buffer,added,removed,recycled,write,sync,total,synced,longest,average"
}
# 2014-06-27 03:17:15.366 UTC "checkpoint complete: wrote 21504 buffers (1.4%); 0 transaction log file(s) added 0 removed 0 recycled; write=8.298 s sync=2.225 s total=10.544 s; sync files=247 longest=0.174 s average=0.009 s"
{
split($19, w, /=/);
split($21, s, /=/);
split($23, t, /=/);
split($26, f, /=/);
split($27, l, /=/);