Skip to content

Instantly share code, notes, and snippets.

View lathiat's full-sized avatar

Trent Lloyd lathiat

View GitHub Profile
@lathiat
lathiat / testmirror.sh
Last active May 28, 2024 05:34
Test download speed and collect data/statistics from rsync.archive.ubuntu.com
#!/bin/bash
set -xe
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
testrun=$(date -Isecond)
mkdir -p ~/test-mirror/${testrun}
cd ~/test-mirror/${testrun}
# ~400M -rw-r--r-- 421,586,560 2024/01/09 17:36:50 linux-source-6.2.0_6.2.0-41.42_all.deb
@lathiat
lathiat / bridge_creation_mtu.bt
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 \
quay.io/iovisor/bpftrace:latest \
@lathiat
lathiat / bridge_flags.py
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 bridge_flags.py
#!/usr/local/bin/drgn -k
# Usage: ./bridge_flags.py 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
lathiat / lp2008509_fix_series_upgrade.py
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
lathiat / juju-run-split.py
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(input_file.read)
ops = {}
@lathiat
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 <trentl@webinabox.net.au>
## (1) Create a new directory, e.g. 'template-builder'
## (2) Download this file and name it Makefile
@lathiat
lathiat / gist:10790374
Created April 15, 2014 23:52
puppet network heira hack
---
network_internal:
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
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|