Skip to content

Instantly share code, notes, and snippets.

View slb350's full-sized avatar
🦙
llama time

Stephen Brandon slb350

🦙
llama time
View GitHub Profile
import boto3
import json
import signal
import sys
import urllib2 #prep for get request on authcache service
import pymysql
import logging
sqs = boto3.resource('sqs', region_name='us-east-1')
from flask import Flask
from flask import json
from flask import request
from boto3.session import Session
import json
import logging
app = Flask(__name__)
session = Session(
require 'sinatra'
require 'redis'
require 'json'
configure do
$redis = Redis.new(host: "localhost", port: "6379")
end
get '/' do
content_type :json
require 'pagerduty'
check1=`redis-cli -h REDIS_HOST llen REDIS_QUEUE1`.to_i
check2=`redis-cli -h REDIS_HOST llen REDIS_QUEUE2`.to_i
pagerduty = Pagerduty.new("PD_API_KEY")
queue = case check1
when 0..20 then "Pass"
else incident = pagerduty.trigger("Queue size is #{check1}")
@slb350
slb350 / idle.sh
Last active August 29, 2015 14:27 — forked from jodiecunningham/idle.sh
Shut down idle AWS plex instance
#!/bin/bash
#set -x
#DEBUG=echo
# Runs via cron to shut down the instance if it's not in use for 5 minutes
# Starts checks after it's been up more than 500secs
# Won't kick you out if you're ssh'ed in and it's idle.
# crontab -l|grep idle
# */6 * * * * /root/bin/idle.sh >/dev/null 2>&1
until $(awk '$1>500{exit 1}' /proc/uptime)
@slb350
slb350 / sara
Last active August 29, 2015 14:22
module.exports = (robot) ->
robot.respond /(.*) sara$/i, (msg) ->
msg.http('http://catfacts-api.appspot.com/api/facts?number=1')
.get() (error, response, body) ->
# passes back the complete reponse
response = JSON.parse(body)
if response.success == "true"
sara_message = response.facts[0]
msg.send sara_message.replace /cat/g, "sara"
else
@slb350
slb350 / ec2.ini
Created February 27, 2015 20:22
EC2 - Polls with Boto (Config)
# Ansible EC2 external inventory script settings
#
[ec2]
# to talk to a private eucalyptus instance uncomment these lines
# and edit edit eucalyptus_host to be the host name of your cloud controller
#eucalyptus = True
#eucalyptus_host = clc.cloud.domain.org
@slb350
slb350 / ec2.py
Created February 27, 2015 20:21
EC2 - Polls w/Boto
#!/usr/bin/env python
import sys
import os
import argparse
import re
from time import time
import boto
from boto import ec2
from boto import rds
######################### ElasticSearch Configuration ########################
# This file is managed by Chef, do not edit manually, your changes *will* be overwritten!
#
# Please see the source file for context and more information:
#
# https://github.com/elasticsearch/elasticsearch/blob/master/config/elasticsearch.yml
#
# To set configurations not exposed by this template, set the
# `node.elasticsearch[:custom_config]` attribute in your node configuration,
@slb350
slb350 / exceldiffs.py
Created January 5, 2015 22:41
excel diffs with pandas
import pandas as pd
import numpy as np
# Define the diff function to show the changes in each field
def report_diff(x):
return x[0] if x[0] == x[1] else '{} ---> {}'.format(*x)
# Read in the two files but call the data old and new and create columns to track
old = pd.read_excel('sample-address-old.xlsx', 'Sheet1', na_values=['NA'])
new = pd.read_excel('sample-address-new.xlsx', 'Sheet1', na_values=['NA'])