Skip to content

Instantly share code, notes, and snippets.

View tcotav's full-sized avatar

James Francis tcotav

View GitHub Profile
@tcotav
tcotav / iptables-block-mysql-log.sh
Created December 7, 2016 01:09
MySQL -- Drop packets on 3306 and log
#!/bin/bash
iptables -N LOG_AND_DROP
iptables -A LOG_AND_DROP -j LOG --log-prefix "Mysql dropped "
iptables -A LOG_AND_DROP -j DROP -p tcp --destination-port 3306 -i bond0
@tcotav
tcotav / kube-apiserver.manifest
Created December 5, 2016 23:21
kube-apiserver.manifest with audit logging turned on AND writing to a volume in /var/log
# Set amount of memory available for apiserver based on number of nodes.
# TODO: Once we start setting proper requests and limits for apiserver
# we should reuse the same logic here instead of current heuristic.
# test_args has to be kept at the end, so they'll overwrite any prior configuration
{
"apiVersion": "v1",
"kind": "Pod",
@tcotav
tcotav / network-test.py
Last active June 26, 2016 22:43
ping script to run in cron to track network outages at home (comcast)
#!/usr/bin/python
import os
import logging
import logging.handlers
log_file_name = '/Users/james/dev/uptime/logs/nettest.log'
logging_level = logging.INFO
import datetime as dt
"""
comcast dns
@tcotav
tcotav / elk-es-cleanup-idx.py
Created June 17, 2016 22:18
simple python script to delete ELK stack indices older than N days. couldn't use curator because of f'd up ssl situation :D
#!/usr/bin/python
import requests
import json
import datetime
"""
Delete any indices older than N days
"""
base_url="https://your-url/"
DELETE_OLDER_THAN=7
@tcotav
tcotav / cleanpods.sh
Last active November 28, 2017 00:33
Kubernetes -- delete all current pods in an RC so they can be replaced
#!/bin/bash
if [ -z "$1" ]
then
echo "requires base pod-name for grep"
exit 1
fi
if [ ! -z "$2" ]
then
@tcotav
tcotav / nope_retrofit.sh
Created June 1, 2016 00:28
retrofit nrpe to CoreOS hosts
#!/bin/bash
# pattern match for targeting
MATCH="-kubenode-"
# location of the google cloud sdk
GCLOUD=~/google-cloud-sdk/bin/gcloud
for i in $(${GCLOUD} compute instances list | grep ${MATCH} | cut -d " " -f 1);do
# gcloud compute instances stop $i
$GCLOUD compute ssh $i "sudo bash -c 'cat <<EOF > /etc/systemd/system/nrpe.service
@tcotav
tcotav / kube-up-coreos-gce.md
Last active April 26, 2016 04:58
kube-up script with CoreOS and GCE
@tcotav
tcotav / prom_nodex_coreos.md
Created April 18, 2016 19:44
Running Prometheus's node_exporter in Docker container for use with CoreOS nodes

ref: (prometheus/node_exporter#66)

docker pull prom/node-exporter
docker run -d -p 9100:9100 -v "/proc:/host/proc" -v "/sys:/host/sys" -v "/:/rootfs" --net="host" prom/node-exporter -collector.procfs /host/proc -collector.sysfs /host/proc -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
@tcotav
tcotav / gceclean.sh
Created April 15, 2016 23:42
Script to clean up a kubernetes dev compute environment in GCE
#!/bin/bash
# we run this at night via cron so our instances don't run for no reason overnight
# we then spin 'em back up in the morning via another script
MATCH="jf" # pattern in all your compute nodes so you can easily match later
ZONE="us-central1-f"
# set this to where ever you installed g cloud sdk
GCLOUD=$HOME/google-cloud-sdk/bin/gcloud
@tcotav
tcotav / hcNotify.go
Created March 23, 2016 01:58
Rudimentary Golang Hipchat Notification Sender -- no frills :)
package hipchat
import (
"bytes"
"encoding/json"
"net/http"
)
type HipchatMsg struct {
Color string `json:"color"`