This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.web | |
import tornado.ioloop | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.write() | |
application = tornado.web.Application([ | |
(r"/", MainHandler), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Install the necessary tools" | |
sudo apt-get update | |
sudo apt-get -y install make flex bison libtool libevent-dev automake pkg-config libssl-dev libboost-all-dev libbz2-dev build-essential g++ python-dev git | |
echo "git cloning Thrift" | |
apt- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM sdurrheimer/alpine-glibc | |
MAINTAINER The Prometheus Authors <[email protected]> | |
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/ \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#host running out of memory! | |
ALERT HighMem | |
IF 100 -(node_memory_MemFree + node_memory_Buffers + node_memory_Cached) / node_memory_MemTotal* 100 > 80 | |
FOR 1m | |
WITH { | |
severity="page" | |
} | |
SUMMARY "Instance {{$labels.host}} has high memory consumption" | |
DESCRIPTION "{{$labels.host}} of job {{$labels.job}} has less than 40% of memory available for more than 1 minutes." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# my global config | |
global: | |
scrape_interval: 15s # By default, scrape targets every 15 seconds. | |
evaluation_interval: 15s # By default, scrape targets every 15 seconds. | |
# scrape_timeout is set to the global default (10s). | |
# Attach these extra labels to all timeseries collected by this Prometheus instance. | |
external_labels: | |
monitor: 'codelab-monitor' |
OlderNewer