Skip to content

Instantly share code, notes, and snippets.

View kd7lxl's full-sized avatar

Tom Hayward kd7lxl

  • Infoblox
  • Tacoma, WA
View GitHub Profile
@kd7lxl
kd7lxl / kubecost-subnets.py
Created November 19, 2021 20:40
Generate helm values for Kubecost network cost allocations
import socket
import requests
import yaml
AWS_IP_RANGES_URL = "https://ip-ranges.amazonaws.com/ip-ranges.json"
def kubecost_direct_classification(kops_subnet):
#!/usr/bin/env bash
# Usage: ./generate_release.sh v3.0.3
USER=
TOKEN=
OWNER="$(basename $(dirname $(pwd)))"
PROJECT="$(basename $(pwd))"
NEW_RELEASE_TAG="$1"
CHANGELOG="CHANGELOG.tmp.md"
docker run -i --rm \
@kd7lxl
kd7lxl / librenms.py
Created December 19, 2018 05:27
Ansible dynamic inventory from LibreNMS
#!/usr/bin/env python
import json
import urllib2
librenms = json.loads(
urllib2.urlopen(urllib2.Request(
'https://librenms.hamwan.org/api/v0/devices',
headers={'X-Auth-Token': ''},
@kd7lxl
kd7lxl / find_invalid_elbs.py
Created October 25, 2018 15:56
Lists AWS ELBs with no valid endpoints
import boto.ec2.elb
def get_elbs_with_no_valid_instances(elb):
"""Finds ELBs with zero instances or where all instances are no longer in service."""
for lb in elb.get_all_load_balancers():
instances = lb.get_instance_health()
if len(instances) == 0:
yield lb
continue
@kd7lxl
kd7lxl / fqdn_sort.py
Created August 22, 2018 15:10
Sorts a list of hostnames by their domain
#!/usr/bin/env python
import fileinput
print "".join(sorted(fileinput.input(), key=lambda fqdn: fqdn.lower().split('.')[::-1])),
@kd7lxl
kd7lxl / ant_to_azel.py
Last active July 23, 2021 18:28
Converts Radio Mobile .ant antenna pattern files to SPLAT! .az/.el format
#!/usr/bin/env python
import sys
from os.path import splitext
def db_to_norm(db):
return 10**(db/10.)
antfilename = sys.argv[1]
@kd7lxl
kd7lxl / genkmz.sh
Last active November 11, 2021 00:07
Runs signalserver and converts the output to a kmz file
#!/bin/bash
while read line
do
echo $line
if [[ $line == Writing* ]]
then
while IFS='"' read -ra writingline
do
filename=${writingline[1]%.*}
done <<< $line
@kd7lxl
kd7lxl / diff_routes.sh
Created August 3, 2017 17:32
Detect a change in the route table
#!/bin/bash
PREVTABLE=/tmp/routes
NEWTABLE=$(mktemp)
ip r > "$NEWTABLE"
if [ -f "$PREVTABLE" ]; then
diff -u "$PREVTABLE" "$NEWTABLE"
fi
mv "$NEWTABLE" "$PREVTABLE"
@kd7lxl
kd7lxl / install_hp_tools.yml
Created April 24, 2017 21:09
Ansible playbook to install HP server management tools
---
- name: Install HP management tools
hosts: hp
become: yes
tasks:
- name: Install pexpect for Ansible expect
apt:
name: python-pexpect
@kd7lxl
kd7lxl / telnet_auth.py
Created March 25, 2017 00:20
Simple telnet credential harvester
# usage: twistd -ny telnet_auth.py
from twisted.conch.telnet import TelnetTransport, AuthenticatingTelnetProtocol
from twisted.internet.protocol import ServerFactory
from twisted.application.internet import TCPServer
from twisted.application.service import Application
log = open('creds.log', 'a')
class TelnetHoneypot(AuthenticatingTelnetProtocol):