Skip to content

Instantly share code, notes, and snippets.

import tornado.web
import tornado.ioloop
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write()
application = tornado.web.Application([
(r"/", MainHandler),
@Dnile
Dnile / okhttp.java
Created January 18, 2015 16:09
android http get with okhttp
String url = "http://api.openweathermap.org/data/2.5/weather?q=London,uk";
OkHttpClient client = new OkHttpClient();
try{
Request request = new Request.Builder()
.url(url)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
@Dnile
Dnile / connect_aws.py
Created February 12, 2015 19:52
just a boto ec2 conenction sequence abstracted
import boto.ec2
import os
access = os.environ['aws_access_key_id']
secret = os.environ['aws_secret_access_key']
conn = boto.ec2.connect_to_region(region, aws_access_key_id=access,
aws_secret_access_key=secret)
import boto
ec2 = boto.connect_ec2()
res = ec2.get_all_instances()
instances = [i for r in res for i in r.instances]
vol = ec2.get_all_volumes()
def attachedvolumes():
print 'Attached Volume ID - Instance ID','-','Device Name'
for volumes in vol:
if volumes.attachment_state() == 'attached':
filter = {'block-device-mapping.volume-id':volumes.id}
import json
import click
import requests
def get_status(node):
es_stats = requests.get("http://%s:8080/_cluster/health?level=indices" % node)
indices = es_stats.json()['indices']
bad_indices = {k:v['status'] for k,v in indices.items() if 'green' not in v['status'] and 'nginx' in k}
for k,v in bad_indices.items():
@Dnile
Dnile / Dockerfile
Last active September 29, 2015 21:51
attempt to run promtheus locally
FROM sdurrheimer/alpine-glibc
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>
WORKDIR /gopath/src/github.com/prometheus/prometheus
COPY . /gopath/src/github.com/prometheus/prometheus
RUN apk add --update -t build-deps tar openssl git make bash curl\
&& source ./scripts/goenv.sh /go /gopath \
&& make build \
&& cp prometheus promtool /bin/ \
FROM prom/prometheus
EXPOSE 9090
VOLUME [ "/prometheus" ]
WORKDIR /prometheus
ENTRYPOINT [ "/bin/prometheus" ]
CMD [ "-config.file=/etc/prometheus/prometheus.yml", \
"-storage.local.path=/prometheus", \
"-alertmanager.url=http://localhost:9093", \
"-web.console.libraries=/etc/prometheus/console_libraries", \
@Dnile
Dnile / alertmanager.yml
Last active May 27, 2016 18:11
alertmanager config
global:
slack_api_url: <hidden>
pagerduty_url: "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
route:
# The labels by which incoming alerts are grouped together. For example,
# multiple alerts coming in for cluster=A and alertname=LatencyHigh would
# be batched into a single group.
group_by: ['alertname','host']
group_wait: 30s
@Dnile
Dnile / alertmanager.log
Created May 27, 2016 19:15
prometheus, no alerts log
This file has been truncated, but you can view the full file.
2016/05/27 06:36:09 http: Accept error: accept tcp [::]:9093: accept4: too many open files; retrying in 1s
2016/05/27 06:36:10 http: Accept error: accept tcp [::]:9093: accept4: too many open files; retrying in 1s
2016/05/27 06:36:11 http: Accept error: accept tcp [::]:9093: accept4: too many open files; retrying in 1s
2016/05/27 06:36:12 http: Accept error: accept tcp [::]:9093: accept4: too many open files; retrying in 1s
2016/05/27 06:36:13 http: Accept error: accept tcp [::]:9093: accept4: too many open files; retrying in 1s
2016/05/27 06:36:14 http: Accept error: accept tcp [::]:9093: accept4: too many open files; retrying in 1s
2016/05/27 06:36:15 http: Accept error: accept tcp [::]:9093: accept4: too many open files; retrying in 1s
2016/05/27 06:36:16 http: Accept error: accept tcp [::]:9093: accept4: too many open files; retrying in 1s
2016/05/27 06:36:17 http: Accept error: accept tcp [::]:9093: accept4: too many open files; retrying in 1s
2016/05/27 06:36:18 http: Accept error: accept tcp [::]:9093:
@Dnile
Dnile / ls_l_proc.txt
Created May 27, 2016 21:17
prometheus issue #143
lrwx------ 1 prometheus prometheus 64 May 27 14:16 0 -> /dev/null
lrwx------ 1 prometheus prometheus 64 May 27 14:16 1 -> /dev/pts/3
lrwx------ 1 prometheus prometheus 64 May 27 14:16 10 -> socket:[285801553]
lrwx------ 1 prometheus prometheus 64 May 27 14:16 100 -> socket:[285878671]
lrwx------ 1 prometheus prometheus 64 May 27 14:16 101 -> socket:[285878812]
lrwx------ 1 prometheus prometheus 64 May 27 14:16 102 -> socket:[285877980]
lrwx------ 1 prometheus prometheus 64 May 27 14:16 103 -> socket:[285881817]
lrwx------ 1 prometheus prometheus 64 May 27 14:16 104 -> socket:[285882535]
lrwx------ 1 prometheus prometheus 64 May 27 14:16 105 -> socket:[285882580]
lrwx------ 1 prometheus prometheus 64 May 27 14:16 106 -> socket:[285884665]