https://gist.github.com/jamespo/b7cb9223dc7382e31ce26baf3f78c90e
transitioning from screen to tmux
GNU screen is deprecated in redhat 7 & unavailable in redhat 8
The usurper tmux is available however, and with a compatibility config (I prefer to set the bind-prefix to ^W) things can be made bearable.
This shell function will help with the muscle memory of screen -r
screen () {
if [[ "$1" == "-r" ]]; then
tmux attach-session
else
tmux $@
fi
}
Writing Python unit tests for HTTP Clients
I have a nagios / icinga HTTP monitor based on PyCurl: check_pycurl3.
Writing tests for this is difficult because:
- It needs to make HTTP requests and get a consistent response (so can’t rely on random internet websites).
- You cannot mock the HTTP requests as the modules for doing this rely on using more “standard” Python HTTP packages (like urllib or requests).
- Just spawning Flask or similar won’t work as it goes into its request loop and won’t process any tests.
So with a little StackExchange googling, you can start Flask in a thread (remember to set daemon=True) like below:
flask = threading.Thread(target=lambda: self.app.run(host=self.host,
port=self.port, debug=False, use_reloader=False),
daemon=True)
flask.start()
You also need to give it some time to start up before tests commence, I’ve used the hacky approach of a 1 second sleep.
To see how I set up routes & inhibit flask startup messages, check the code!
Updated Gnome extensions for Gnome 46
gnome-extensions – including appindicator & gestureImprovements.
Skip synology @eaDir with ibroadcast-uploader
user_prefs not getting read on spamassassin / postfix / procmail setup on debian?
Seeing errors like “spamd: still running as root: user not specified with -u, not found, or set to root, falling back to nobody” in mail log?
Put
DROPPRIVS=yes
in /etc/procmailrc
dnf upgrade crashing on free oracle cloud vms running OEL8
There are 2 reasons for this: the memory on these VMs is small (668MB) & DNF is badly written and uses 100s of MBs. Secondly Oracle Linux includes a lot of repos.
1. install microdnf by wgetting it (as dnf is failing)
wget https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64/getPackage/libpeas-1.22.0-6.el8.x86_64.rpm
wget https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64/getPackage/microdnf-3.4.0-4.el8.x86_64.rpm
rpm -ivh *.rpm
2. Upgrade base repos
microdnf update –disablerepo=* –enablerepo=ol8_baseos_latest –enablerepo=ol8_appstream
Whoops
Check if a pidfile is running in bash
test -f /run/icinga2/icinga2.pid && test -d /proc/$(< /run/icinga2/icinga2.pid)