Skip to content

Instantly share code, notes, and snippets.


Franz Bettag fbettag

View GitHub Profile
fbettag / juniper-junos-bgp-peers-to-yaml.awk
Last active Jan 13, 2021
AWK script which takes the output of "show configuration protocols bgp" on a Juniper Router and converts it into yaml. Can be used to convert an old configuration on a router into Ansible JunOS style. Should be adapter to your configuration style and case.
View juniper-junos-bgp-peers-to-yaml.awk
#!/usr/local/bin/gawk -f
/neighbor|peer-as|description|apply-group|authentication-key/ {
for (i=7; i<=NF; i++) {
out=out" "$i
gsub(/"/, "", out);
if ($6 == "neighbor") {
fbettag / cwmrc
Created Jan 17, 2019
tiling windows in cwm and other managers that don't support top-right, top-left etc. Works with multiple monitors using mmutils.
View cwmrc
bind-key 4-Up "bin/ top"
bind-key 4-Down "bin/ bottom"
bind-key 4-Left "bin/ left"
bind-key 4-Right "bin/ right"
bind-key C4-Up "bin/ top-right"
bind-key C4-Left "bin/ top-left"
bind-key C4-Down "bin/ bottom-left"
bind-key C4-Right "bin/ bottom-right"
fbettag /
Last active Aug 5, 2018
SmartOS Zone Migration script that takes care of installing the required image on the target compute node. Just keep this script on the headnode.
# Franz Bettag <> - August 2018
# Script script migrates Zones/KVMs on Joyent SmartOS from one node to another.
# First it creates a new VM on the target from the same config as the original VM.
# It leaves out the nics section as to not run into any conflicts with the currently running machine.
# We then zfs send an intial snapshot of the original VM to the target.
# Then we shutdown the original VM and create another snapshot.
# After the last snapshot has been transferred, we update the new VM with nics and start it up.
# Cleanup of course.
fbettag /
Created Jul 25, 2018
rudder agent hook script to be placed into /var/rudder/hooks.d
# All available metadata within the sdc: namespace gets converted into vars.
VARS="uuid server_uuid datacenter_name alias billing_id brand cpu_shares create_timestamp dns_domain hostname image_uuid last_modified limit_priv max_locked_memory max_lwps max_physical_memory max_swap owner_uuid quota state tmpfs zfs_io_priority zonename zonepath"
# The sdc: namespace.
for key in $VARS
IGNORE="'U7PG2|cron|no matching key|[Ii]nvalid user|preauth|Timeout before auth|service=retention|-- MARK --|Log statistics|ntpd|tsm1|last message repeated'"
CURLOG="egrep -ve $IGNORE $LOG | tail -n $LINES"
NOWLOG="tail -Fn 0 $LOG | egrep -ve $IGNORE"
ssh tail@data "$CURLOG && $NOWLOG" | ccze -A
fbettag / .Xmodmap
Created Mar 30, 2018
Logitech G610 xmodmap bindings for multimedia keys
View .Xmodmap
! logitech g610 multimedia keys
keycode 170 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume
keycode 92 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume
keycode 189 = XF86AudioPrev NoSymbol XF86AudioPrev
keycode 190 = XF86AudioNext NoSymbol XF86AudioNext
keycode 184 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause
keycode 207 = XF86AudioMute NoSymbol XF86AudioMute
keycode 147 = XF86AudioStop XF86Eject XF86AudioStop XF86Eject
fbettag / freebsd dalmatiner db 0.3.3 port - almost working
Created Nov 15, 2017
Almost working port of dalmatinerdb. Works when you make package manually, but doesn't when poudriere tries to do offline/cleanroom builds. good luck, i'm out of time on this. HOW CAN A DATABASE CLAIM TO BE OPTIMIZED FOR ZFS AND NOT HAVE A WORKING FREEBSD PORT? WTF GUYS
View freebsd dalmatiner db 0.3.3 port - almost working
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
# This archive contains:
# databases
# databases/dalmatinerdb
# databases/dalmatinerdb/Makefile
fbettag / gist:fe02609c40516a58dd1e82241a65597a
Created Sep 14, 2017
create logstash.conf mutations/conversions for INT and NUMBER out of your patterns folder
View gist:fe02609c40516a58dd1e82241a65597a
cat patterns/*/*|egrep -oe '(BASE10|INT|NUMBER|BASE16FLOAT):[^}]+'|grep :|sort|uniq |awk -F: '{if($1 == "NUMBER"||$1 == "BASE16FLOAT") print "\""$2"\" => \"float\""; else print "\""$2"\" => \"integer\""}'
fbettag /
Last active Sep 9, 2017
SOLR dump and restore script using plain sh and bc, does pagination and dumps to file, also forks for insertion
# Dumps a subset of one Solr core and loads it into another one.
if [ $# -lt 4 ]; then
echo "Usage: $0 <source> <target> <limit> [core1 core2...]"
echo " $0 http://source.solr:8983/solr http://target.solr:8983/solr 100000 core1 core2"
exit 1
fbettag /
Last active Dec 5, 2015
Find harddisks programmatically in shell under FreeBSD while also identifying SMART capability
DEVICES=`/sbin/camcontrol devlist | /usr/bin/egrep -oe '\(\w*\d*'| /usr/bin/sed -e 's;^(;;g'`
for DEVICE in $DEVICES; do
NEED_SMART=`/sbin/camcontrol identify $DEVICE | /usr/bin/egrep -coe '^SMART.*yes.*no.*'`
if [ $NEED_SMART -eq 1 ] && [ -f "/usr/local/sbin/smartctl" ]; then
/usr/local/sbin/smartctl -s on /dev/$DEVICE
[ $? -eq 0 ] && echo "Enabled SMART for $DEVICE" 1>&2 # output to STDERR so people see it while piping ;)