Skip to content

Instantly share code, notes, and snippets.

debian@bbb-test:~$ vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
4 0 0 6088 19916 271064 0 0 25 20 17 32 18 12 69 0 0
0 0 0 6120 19916 271064 0 0 0 0 1334 4098 13 20 67 0 0
0 0 0 6120 19916 271064 0 0 0 0 1554 4046 13 19 68 0 0
0 0 0 6120 19924 271056 0 0 0 16 929 2443 10 8 81 1 0
0 0 0 6120 19924 271064 0 0 0 0 1611 4128 24 20 56 0 0
0 0 0 6120 19924 271064 0 0 0 0 919 2443 6 11 83 0 0
0 0 0 5996 19924 271064 0 0 0 0 1240 3312 29 28 42 0 0
@dstrbad
dstrbad / tmux-cheatsheet.markdown
Created November 28, 2017 16:37 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@dstrbad
dstrbad / jenkins-go.sh
Created November 28, 2016 15:37 — forked from marinbek/jenkins-go.sh
jenkins golang setup
export GOROOT=/usr/local/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH:$WORKSPACE/bin
export GOPATH=$WORKSPACE
git config url."git@github.com:".insteadOf "https://github.com/"
go get github.com/AlekSi/gocov-xml
go get github.com/axw/gocov/gocov
mkdir -p $GOPATH/src/github.com/NextUserSF/

Keybase proof

I hereby claim:

  • I am dstrbad on github.
  • I am dstrbad (https://keybase.io/dstrbad) on keybase.
  • I have a public key ASA2L1_UMoX-kPGjT5qL2Uq9HepKpype7bczEVLy9MFlCQo

To claim this, I am signing this object:

from tastypie import fields
from tastypie.authentication import Authentication
from tastypie.authorization import Authorization
from tastypie.bundle import Bundle
from tastypie.exceptions import NotFound
from tastypie.resources import Resource
# a dummy class representing a row of data
class Row(object):

Application specific host grouping in Riemann-dash

It is generally desirable to group all the hosts for a specific service into a single dashboard view. For example, all the web servers are in single view while all the database servers are in another view.

This is usually not an issue when you are sending custom metrics using Riemann client. However, there are cases where you are using something that you do not control how the metrics are being sent. i.e., Riemann-tools.

Since Riemann-tools scripts are application agnostic, in order for the dashboard view to group hosts, we must inject some application specific information into the tags field. Tags is a collection of arbitrary strings. In the case of Riemann-tools scripts you can pass in arbitrary strings on the command line.

riemann-health --host 127.0.0.1 --tag "prod" --tag "webserver"

SELECT 'drop table '||n.nspname ||'.'|| c.relname||' CASCADE;' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
AND n.nspname = 'destination_schema';
SELECT 'create table '||n.nspname ||'.'|| c.relname||' as select * from source_schema.' || c.relname||';' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
SELECT 'UNLOAD (\'select * from '||n.nspname ||'.'|| c.relname||'\') TO \'s3://bucket/' || c.relname || '_\';' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
AND n.nspname LIKE 'nu_alibris';
SELECT 'COPY ' || n.nspname ||'.'|| c.relname ||' from \'s3://bucket/' || c.relname || '_\';' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
class Daemon:
"""
A generic daemon class.
Usage: subclass the Daemon class and override the run() method
@dstrbad
dstrbad / haproxy.cfg
Last active August 29, 2015 13:57 — forked from rnewson/haproxy.cfg
# Bind SSL port with PFS-enabling cipher suite
bind :443 ssl crt path_to_certificate no-tls-tickets ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-RC4-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES128-SHA:AES256-SHA256:AES256-SHA:RC4-SHA
# Distinguish between secure and insecure requests
acl secure dst_port eq 443
# Mark all cookies as secure if sent over SSL
rsprep ^Set-Cookie:\ (.*) Set-Cookie:\ \1;\ Secure if secure
# Add the HSTS header with a 1 year max-age