Skip to content

Instantly share code, notes, and snippets.

View mdfranz's full-sized avatar

Matt Franz mdfranz

  • Lutherville Timonium MD
  • 18:20 (UTC -04:00)
View GitHub Profile
@mdfranz
mdfranz / gist:3260992
Created August 5, 2012 01:22
Azure Linux Agent
POST /machine?comp=health HTTP/1.1
Host: 10.76.84.160
Accept-Encoding: identity
Content-Length: 439
Content-Type: text/xml; charset=utf-8
x-ms-version: 2011-12-31
x-ms-agent-name: WALinuxAgent
<?xml version="1.0" encoding="utf-8"?><Health xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GoalStateIncarnation>1</GoalStateIncarnation><Container><ContainerId>f5940043-dbed-419c-9122-d77a4ac854b7</ContainerId><RoleInstanceList><Role><InstanceId>79247837105c4470b89352eda4b10942.firstone</InstanceId><Health><State>Ready</State></Health></Role></RoleInstanceList></Container></Health>HTTP/1.1 200 OK
Content-Length: 0
@mdfranz
mdfranz / gist:6073985
Created July 24, 2013 19:58
How to specify hosts in variables for stuff like access control lists
$ ansible-playbook -i hosts -c local access.yaml
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [127.0.0.1]
TASK: [template src=./access.j2 dest=./access.conf] ***************************
changed: [127.0.0.1]
@mdfranz
mdfranz / gist:6147964
Created August 3, 2013 21:01
VPC Region Fun with Boto
# Not sure why I had to do this, seems like I shouldn't have to
def region_from_str(s):
regions = boto.ec2.regions()
for r in regions:
if s == r.name:
return r
vpc_conn = VPCConnection(region=region_from_str(region))
@mdfranz
mdfranz / gist:6148318
Created August 3, 2013 23:03
Getting the first two /24's of a /16 (well sort of) using Python netaddr
In [1]: import netaddr
In [2]: vpc_block = netaddr.IPNetwork("192.168.0.0/16")
In [3]: vpc_subnets = list(vpc_block.subnet(24))
In [4]: vpc_subnets[1:3]
Out[4]: [IPNetwork('192.168.1.0/24'), IPNetwork('192.168.2.0/24')]
In [5]: str(vpc_subnets[2])
Out[5]: '192.168.2.0/24'
Guys,
I don't want to be rude but, Linux 3.13 sucks a lot.
I'm wondering here, for God's sake, why Ubuntu 14.04 comes with this lame kernel? What Ubuntu Kernel Team have in mind?!
Mark Shuttlework must say something about this situation. What he is gonna do? I really t want to know that.
I'm a HUGE fan of Ubuntu, and I mean it, I have no plans to switch off Ubuntu and I'll stick with 14.04 but, definitely, Linux 3.13 was a bad, bad choice for a LTS version like Trusty.
@mdfranz
mdfranz / walker.go
Last active August 29, 2015 14:16
Simple Directory Lister
// From https://www.socketloop.com/tutorials/golang-read-directory-content-with-filepath-walk
package main
import (
"path/filepath"
"os"
"flag"
"fmt"
)
#!/usr/bin/env python
import requests
import sys
import json
from datetime import date, timedelta
#Your PagerDuty API key. A read-only key will work for this.
AUTH_TOKEN = 'YOUR_API_KEY'
#The API base url, make sure to include the subdomain
@mdfranz
mdfranz / gist:ca1f27541bb5dd74086a
Created July 18, 2015 20:16
Simple ElasticSearch-DSL Python Example
if __name__ == "__main__":
c = Elasticsearch("http://192.168.2.218:9200")
f = open(sys.argv[1])
for line in f:
# Convert public_hostname to IPs because hostname lookups are failing in ES for some reason
if line.find("ec2") > -1:
host = socket.gethostbyname(line.rstrip().lstrip())
else:
host = line.rstrip().lstrip()
@mdfranz
mdfranz / gist:973013130d3630aadcb7
Created July 25, 2015 16:37
Most Simple Way to Turn on Python ElasticSearch logging
tracer = logging.getLogger('elasticsearch.trace')
tracer.setLevel(logging.DEBUG)
tracer.addHandler(logging.FileHandler('/tmp/es-client.log'))
@mdfranz
mdfranz / gist:1dcfacc8994ed4c74e4379dee0db4dba
Created May 29, 2017 20:57
memorial-day-systemd-docker-fun
root@docker01:/etc/systemd/system# cat dockerlog-json.service
[Unit]
Description=Send Docker logs via Journalctl to Syslog (JSON)
[Service]
TimeoutStartSec=0
ExecStart=/bin/sh -c '/bin/journalctl -u docker.service -o json -f | /usr/bin/ncat 192.168.2.136 1515'
Restart=always
RestartSec=5s