Skip to content

Instantly share code, notes, and snippets.

View mrpatrick's full-sized avatar

Patrick Tully mrpatrick

View GitHub Profile
@mrpatrick
mrpatrick / apache_dump_loaded_modules.sh
Created February 22, 2013 18:01
Display loaded apache modules
httpd -t -D DUMP_MODULES
# dig all records (except CNAMES)
dig +nocmd yourdomain.com any +multiline +noall +answer
# dig A records for www and @
dig a www.domainname.com
dig a domainname.com
@mrpatrick
mrpatrick / newrelic_deploy.sh
Created March 8, 2013 17:46
Send a newrelic deploy message via their API
curl -H "x-api-key:YOUR_API_KEY_HERE" -d "deployment[app_name]=iMyFace.ly Production" -d "deployment[description]=This deployment was sent using curl" -d "deployment[changelog]=many hands make light work" -d "deployment[user]=Joe User" https://api.newrelic.com/deployments.xml
curl -u [user]:[pass] 'http://[subdomain].loggly.com/api/search?q=404'
@mrpatrick
mrpatrick / puppet_rpm_55_fix.sh
Last active December 15, 2015 16:09
rpm puppet fix
rpm -e puppetlabs-release-5-6.noarch
@mrpatrick
mrpatrick / flush_dns_cache.sh
Created April 17, 2013 16:09
If DNS goes wonky and some requests through gil hit krusty for random URLs, run this to flush the DNS cache on linux
sudo /usr/sbin/nscd -i hosts
@mrpatrick
mrpatrick / ssl_expire_days.sh
Created May 7, 2013 18:42
Print how many days left until an SSL certificate file expires. Usage: ssl_expire_days CERTFILE
#!/bin/sh
ssl_expire_days() {
# Show usage info if not called with a certificate file
if [ $# -eq 0 ]; then
echo "Usage: ssl_expire_days CERTFILE"
return 0
fi
cert=$1
@mrpatrick
mrpatrick / ssl_expire_days.py
Last active December 17, 2015 03:29
Print how many days left until an SSL certificate file expires. Usage: ssl_expire_days.py CERTFILE
import time
import datetime
import subprocess
import sys
cert = sys.argv[1]
date_format = "%m/%d/%Y"
p = subprocess.Popen("openssl x509 -noout -in " + cert + " -enddate | sed 's/^[a-zA-Z]*=//g' | xargs --null date +" + date_format\
+ " -d",stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
@mrpatrick
mrpatrick / pre-commit-puppet
Last active December 20, 2015 06:58 — forked from fluxrad/pre-commit
Removing puppet-lint validation and from check
#!/bin/bash
# pre-commit git hook to check the validity of a puppet manifest
#
# Prerequisites:
# gem install puppet-lint puppet
#
# Install:
# /path/to/repo/.git/hooks/pre-comit
echo "### Checking if puppet manifests are valid ###"
RewriteCond %{HTTP_HOST} ^121\.12\.12\.123
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]