Skip to content

Instantly share code, notes, and snippets.

@dgulinobw
dgulinobw / BAD: syslog with raft_protocol=3
Last active August 8, 2017 19:21
Cluster of 5 running 0.9.0 will not elect a leader w/raft_protocol = 3
Aug 8 16:46:21 consul-qa-aws05 systemd[1]: Starting Consul service discovery agent...
Aug 8 16:46:21 consul-qa-aws05 systemd[1]: Started Consul service discovery agent.
Aug 8 16:46:21 consul-qa-aws05 consul[6268]: ==> WARNING: LAN keyring exists but -encrypt given, using keyring
Aug 8 16:46:21 consul-qa-aws05 consul[6268]: ==> WARNING: WAN keyring exists but -encrypt given, using keyring
Aug 8 16:46:21 consul-qa-aws05 consul[6268]: ==> WARNING: Expect Mode enabled, expecting 5 servers
Aug 8 16:46:21 consul-qa-aws05 consul[6268]: ==> Starting Consul agent...
Aug 8 16:46:21 consul-qa-aws05 consul[6268]: raft: Restored from snapshot 4-295004-1502204270457
Aug 8 16:46:21 consul-qa-aws05 consul[6268]: raft: Initial configuration (index=298061): [{Suffrage:Voter ID:01b365e4-dc5f-a730-0744-2315187d31c7 Address:34.228.202.214:8300} {Suffrage:Voter ID:ac31e8ef-a1b9-3ecd-ee1f-b4e2326ac5ee Address:52.1.85.126:8300} {Suffrage:Voter ID:6d2a07da-d73e-f007-7e8f-f22d8e93b0c0 Address:34.207.18.6:8300} {Suffrage:Nonvot
@dgulinobw
dgulinobw / parse_tcpdump_udp_53.py
Created March 17, 2017 21:41
Create a list of timestamp,name,response_time (do_dump_report=True), either/or/and a list of name,total queries, response time avg (do_avg_report=True). Use: /usr/sbin/tcpdump -vvv -s 0 -l port 53 -w log.pcap; python parse_tcpdump_udp_53.py log.pcap
#!/usr/bin/env python
from __future__ import print_function
import sys
import pyshark
from collections import defaultdict
filename = sys.argv[1]
do_dump_report=False
do_avg_report=True
@dgulinobw
dgulinobw / dnsmasq_cache_report.py
Created March 17, 2017 17:13
Report on cache utilization of dnsmasq
#!//usr/bin/env python
from __future__ import print_function
import sys
from collections import defaultdict
filename = sys.argv[1]
queries = defaultdict(lambda: defaultdict(float))
totals= defaultdict(float)
with open(filename) as f:
for line in f.readlines():
@dgulinobw
dgulinobw / gen_certs.sh
Created January 25, 2017 21:59
Script for generating, CA, server, and client certs
#!/bin/bash
# USAGE: > gen_certs.sh <root cert name> <server cert name> <client cert name>
if [ "$#" -ne 3 ]; then
echo "Illegal arguments, USAGE: > gen_certs.sh <root cert name> <server cert name> <client cert name>"
exit 1
fi
mkdir testca
cd testca
mkdir certs private
@dgulinobw
dgulinobw / pagerduty_get_incidents.py
Created January 11, 2017 00:28
Lists top 10 PagerDuty incident services, and top 10 incident summaries
#!/usr/bin/env python
from __future__ import print_function
import json
import re
from easyprocess import EasyProcess
import pandas as pd
more = True
page_size = 25
offset = 0
@dgulinobw
dgulinobw / hosts
Created January 9, 2017 19:14
Way to test ansible jinja templates (.j2) independently from playbooks
#add local to existing ansible hosts, to get variable from your hosts
[local]
127.0.0.1
[app]
test1 app_name=app1
test2 app_name=app2
@dgulinobw
dgulinobw / show_limits.sh
Last active August 13, 2021 12:05
Show percentage used of 1) per-process ulimit open files, and 2) system-wide open files limit.
#!/bin/bash
printf "%-20s %10s %10s %14s\n" "Process" "Ulimit" "Used" "% Ulimit Used"
length=62
printf -v line '%*s' "$length"
echo ${line// /-}
# gather proceses to list from all of /var/run/
for f in $(find /var/run/ -type f -name "*.pid" | sort)
# gather processes to list from monit
#for f in $(grep pidfile /etc/monit.d/* | awk '{print $6}' | sort)
@dgulinobw
dgulinobw / r53_query_ip.sh
Created June 15, 2016 19:54
Search all your AWS r53 DNS zones for records that point to specified IP address
#!/bin/bash
ip=${1}
zones=$(aws route53 list-hosted-zones | jq '.HostedZones[] | .Id' | awk -F"/" '{print $3}' | tr -d '"')
for zone in ${zones}
do
aws route53 list-resource-record-sets --hosted-zone-id=${zone} | jq '.ResourceRecordSets[] | select(.ResourceRecords[0].Value == "'${ip}'")'
done
@dgulinobw
dgulinobw / iam_scan.py
Last active November 14, 2019 14:30
List all IAM policies in account. Pipe to grep to find who has access to what.
#!/usr/bin/env python
from __future__ import print_function
import boto3
from pygments import highlight, lexers, formatters
from botocore.exceptions import ClientError
iam = boto3.resource('iam')
s3 = boto3.client('s3')
@dgulinobw
dgulinobw / hightlight_aws_ips.py
Created June 22, 2015 22:38
Takes stdin, highlights the IPs that are in a AWS IP range
#!/usr/bin/env python
from __future__ import print_function
import requests
import json
import ipaddr
import sys
from blessings import Terminal
import re
import string