Skip to content

Instantly share code, notes, and snippets.

View lathiat's full-sized avatar

Trent Lloyd lathiat

View GitHub Profile
lathiat /
Last active August 10, 2023 01:40
bpftrace script to check the MTU passed on bridge creation
#!/usr/bin/env bpftrace
// Probe br_dev_newlink and see if IFLA_MTU was passed in at creation
docker run -ti -v /usr/src:/usr/src:ro \
-v /lib/modules/:/lib/modules:ro \
-v /root:/root:ro \
-v /sys/kernel/debug/:/sys/kernel/debug:rw \
--net=host --pid=host --privileged \ \
lathiat /
Created July 28, 2023 14:08
Returns the internal linux bridge flags, was written in order to inspect whether BROPT_MTU_SET_BY_USER was set for a given bridge.
root@mtutest:~# cat
#!/usr/local/bin/drgn -k
# Usage: ./ bridge_interface_name
# Returns the internal bridge flags, was written in order to inspect whether
# BROPT_MTU_SET_BY_USER was set for a given bridge.
import sys
from drgn import NULL, Object, cast, container_of, execscript, offsetof, reinterpret, sizeof
lathiat /
Created July 26, 2023 00:52
Fix broken series upgrade (Launchpad Bug #2008509)
import ssl
import pymongo
import yaml
import glob
import sys
import os
import urllib
# Find juju machine agent
agents = glob.glob('/var/lib/juju/agents/machine-*')
lathiat /
Created November 16, 2020 08:47
Split the output from 'juju-run' into multiple files and process the escaped string
#!/usr/bin/env python3
import os
import re
import pprint
import sys
import yaml
if len(sys.argv) <= 1:
print("Usage: juju-split FILE_NAME")
#!/usr/bin/env ruby
require 'pp'
require 'json'
require 'date'
input_fn = ARGV[0]
input_file = open(input_fn)
j = JSON.parse(
ops = {}
lathiat / gist:30ba24de073d45b0979a
Last active August 29, 2015 14:01
OnApp template creator for Ubuntu 14.04 Trusty Tahr
## OnApp template creator Makefile for Ubuntu 14.04
## Creates an OnApp compatible template from the Ubuntu cloud base image
## You can run this script continiously to update the image
## You will want to customise the timezone and mirror
## Version 0.1 2014-05-07
## Trent Lloyd <>
## (1) Create a new directory, e.g. 'template-builder'
## (2) Download this file and name it Makefile
lathiat / gist:10790374
Created April 15, 2014 23:52
puppet network heira hack
ipaddress: "%{::ipaddress_eth1}"
ipaddress6: "%{::ipaddress6_eth1}"
network: "%{::network_eth1}"
netmask: "%{::netmask_eth1}"
prefixlen: "%{::prefixlen_eth1}"
netcidr: "%{::netcidr_eth1}"
netcidr6: "%{::netcidr6_eth1}"
ipcidr: "%{::ipcidr_eth1}"
lathiat / gist:10790228
Created April 15, 2014 23:50
puppet interfaces ipaddr prefixlen
require 'ipaddr'
require 'puppet/util/ipcidr'
interfaces = Facter.value('interfaces')
# If we do not have any interfaces, then there are no requested attributes
unless interfaces == :undefined
interfaces = interfaces.split(',')
interfaces.each do |iface|