Skip to content

Instantly share code, notes, and snippets.

Avatar

David Wittman DavidWittman

View GitHub Profile
@DavidWittman
DavidWittman / supermicro-bmc-reset.sh
Created Sep 11, 2014
Issues a reset of the SuperMicro BMC via the web interface
View supermicro-bmc-reset.sh
#!/usr/bin/env bash
# Issues a reset of the SuperMicro BMC via the web interface
#
# usage: supermicro-bmc-reset.sh <ipmi-host>
# e.g.: supermicro-bmc-reset.sh 10.0.0.1
#
set -x
@DavidWittman
DavidWittman / clouddns-export.py
Last active Dec 12, 2018
Exports all domains for a Rackspace Cloud account in BIND9 format
View clouddns-export.py
#!/usr/bin/env python
import json
import os
import time
import clouddns
USERNAME = ''
APIKEY = ''
@DavidWittman
DavidWittman / supermicro-psblock-fix.expect
Last active Oct 25, 2018
This expect script secures SuperMicro IPMI implementations which are vulnerable to viewing the IPMI password in plaintext on port 49152.
View supermicro-psblock-fix.expect
#!/usr/bin/expect -f
# This script secures SuperMicro IPMI implementations which are vulnerable
# to viewing the IPMI password in plaintext on port 49152. It does this by
# using the shell available in some SuperMicro BMCs to drop traffic to port
# 49152 in iptables.
#
# See http://blog.cari.net/carisirt-yet-another-bmc-vulnerability-and-some-added-extras/
# for more details on the vulnerability.
#
@DavidWittman
DavidWittman / mongo-ansible.py
Last active Aug 4, 2018
MongoDB-backed dynamic inventory script for Ansible
View mongo-ansible.py
#!/usr/bin/env python
#
# MongoDB-backed dynamic inventory script for Ansible
# http://docs.ansible.com/intro_dynamic_inventory.html
import os
from argparse import ArgumentParser
import pymongo
@DavidWittman
DavidWittman / wireshark-analysis.md
Last active Jul 21, 2018
Outline for Packet Analysis with Wireshark
View wireshark-analysis.md

Packet Analysis with Wireshark

Links

Common filters

Source IP is 192.168.1.1

ip.src == 192.168.1.1

@DavidWittman
DavidWittman / python-nested_list_comprehensions.md
Created Jul 26, 2012
Nested list comprehensions in Python
View python-nested_list_comprehensions.md

Nested list comprehensions in Python

For some reason or another, I'm always second guessing myself when writing nested list comprehensions. Here's a quick example to clarify what's going behind the scenes:

>>> words = ["foo", "bar", "baz"]
>>> [letter for word in words for letter in word]
['f', 'o', 'o', 'b', 'a', 'r', 'b', 'a', 'z']
@DavidWittman
DavidWittman / merge-s3-parts.sh
Created Dec 23, 2015
Script to merge .part files from Amazon S3
View merge-s3-parts.sh
#!/usr/bin/env bash
if [[ $# -ne 1 ]]; then
echo "Merge matching *.part files in a directory"
echo
echo "usage: $0 <directory>"
exit 1
fi
DIRECTORY="$1"
@DavidWittman
DavidWittman / saltstack-devstack.md
Last active Mar 29, 2018
Automated DevStack deployments on Rackspace with salt-cloud
View saltstack-devstack.md

Automated DevStack deployments on Rackspace with salt-cloud

Preparation

Install salt-master and salt-cloud

These instructions will install salt-master and salt-cloud on recent Ubuntu releases. Consult the SaltStack Installation Documentation should you require instructions for other distributions.

echo deb http://ppa.launchpad.net/saltstack/salt/ubuntu `lsb_release -sc` main | sudo tee /etc/apt/sources.list.d/saltstack.list
@DavidWittman
DavidWittman / when-will-my-lenovo-arrive.sh
Last active Mar 21, 2017
Scrape the Lenovo order details page and print the estimated arrival date.
View when-will-my-lenovo-arrive.sh
#!/usr/bin/env bash
# When will my Lenovo order arrive?
#
# I grew impatient while waiting for my Thinkpad to ship, and the arrival date
# kept changing, so I wrote this script to scrape their order details page.
#
# Might not work on all platforms, and it's parsing HTML with sed, so there be
# plenty of dragons within this script.
@DavidWittman
DavidWittman / elasticsearch_primary_shards_per_node.md
Last active Mar 19, 2017
One-liner to list the number of primary shards per data node in Elasticsearch
View elasticsearch_primary_shards_per_node.md

List the number of primary shards per data node in Elasticsearch:

curl -s localhost:9200/_cat/shards?h=node,prirep | awk '
$2 == "p" { 
  result[$1] += 1; total += 1
}
END {
  for (var in result)
    printf "%s\t%s (%0.2f%%)\n",var,result[var],result[var]/total*100
You can’t perform that action at this time.