haproxy: Monitor PostgreSQL for current master

There are couple of methods for haproxy to monitor what PostgreSQL instance is currently master so that “dumb” clients can always write to a PostgreSQL instance (instead of connecting to the standby node). First there is the send-binary method by replicating the PostgreSQL V3 protocol but requires trusted connection and is TCP/IP only (no SSL). Another issue is that haproxy terminates the connection dirty when connecting to standby instances. Another method is letting haproxy call xinetd service that runs script to check if the current node is the master. ...

September 24, 2019

vlan bridges in netplan

Took me a while to figure this one out in the netplan yaml syntax: network: version: 2 renderer: networkd ethernets: eno1: dhcp4: no dhcp6: no bridges: br20: dhcp4: no dhcp6: no interfaces: [ vlan20 ] addresses: [ 192.168.20.5/24 ] gateway4: 192.168.20.1 nameservers: addresses: - "192.168.20.1" br40: dhcp4: no dhcp6: no interfaces: [ vlan40 ] vlans: vlan20: id: 20 link: eno1 dhcp4: no dhcp6: no vlan40: id: 40 link: eno1 dhcp4: no dhcp6: no Bonus .vimrc settings for yaml ...

March 21, 2019

Pipe cron to syslog/journald

Simple way to pipe cron script output to journalctl / syslog MAILTO="" * * * * * user (echo "testing") 2>&1 | logger -t tag-to-use gives following in journalctl $ journalctl SYSLOG_IDENTIFIER=tag-to-use -- Logs begin at Tue 2019-02-26 16:48:53 UTC, end at Fri 2019-03-08 22:12:03 UTC. -- Mar 08 22:04:01 server tag-to-use[25769]: testing

March 9, 2019

Convert PostgreSQL cluster to use page checksums

When upgrading PostgreSQL cluster from one major version to another you cannot use pg_upgrade tool to upgrade/convert cluster with page checksums disabled to a cluster with page checksums enabled. Instead you have to do dump and restore. On Debian/Ubuntu based systems this is made easier using the pg_createcluster / pg_dropcluster commands. Here I’m converting a PostgreSQL 11 cluster named 11/main (with no page checksums enabled) to new cluster named 11/data with page checksums enabled. ...

February 26, 2019

View CPU microcode revision from powershell

A small powershell snippet to show what CPU microcode revision is running and what microcode revision the BIOS provides. $registrypath = "Registry::HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\" $processor = (Get-ItemProperty -Path $registrypath )."ProcessorNameString" $biosMicrocode = (Get-ItemProperty -Path $registrypath )."Previous Update Revision" $runningMicrocode = (Get-ItemProperty -Path $registrypath )."Update Revision" # Convert to string and remove leading zeros $biosMicrocodeInHex = (-join ( $biosMicrocode[0..4] | foreach { $_.ToString("X2") } )).TrimStart('0') $runningMicrocodeInHex = (-join ( $runningMicrocode[0..4] | foreach { $_.ToString("X2") } )).TrimStart('0') Write-Host "CPU: $processor" Write-Host "BIOS microcode revision: 0x$biosMicrocodeInHex" Write-Host "Current microcode revision: 0x$runningMicrocodeInHex" Example output: ...

June 28, 2018

Blacklist bad memory addresses in Windows

Update: Following guide might not work since Predictive Failure Analysis (PFA) memory settingsare not working in Windows 10 2004 and 20H2 releases. See discussion here. I recently experienced random MEMORY_MANAGEMENT BSOD on my personal computer. When consulting Microsoft Dev Center for the error code it indicated a issue with the RAM. The computer is 6 years old and only has 8 GB of RAM (two sticks) I’m not about to spend money to replace the RAM. ...

June 22, 2018