Monitoring cloudflared for fun and profit

This is a very hacky script for monitoring cloudflared, it requires curl and jq, which I think you should have on there anyway

You need the following line in the config.yml file, which sets cloudflared to expose the metrics/monitoring endpoint, or --metrics localhost:40355 on the command line:

metrics: localhost:40355

And… here’s the script. TL;DR, it checks the /ready endpoint, which returns {"status":200,"readyConnections":4} on good, or a 503 on not-working.

#!/bin/bash

SYSTEMD_TOPIC="cloudflared_monitoring"
METRICS_PORT="40355"
CLOUDFLARED_STATUS="$( curl --silent --max-time 5 "http://localhost:${METRICS_PORT}/ready" | jq -r '.status' )"
if [ "$CLOUDFLARED_STATUS" -ne 200 ]; then	
    echo "cloudflared status: ${CLOUDFLARED_STATUS} restarting." | /usr/bin/systemd-cat -t "${SYSTEMD_TOPIC}"
    /bin/systemctl restart cloudflared 2>&1 | sudo /usr/bin/systemd-cat -t "${SYSTEMD_TOPIC}"
else
    echo "cloudflared status: ${CLOUDFLARED_STATUS} OK" | /usr/bin/systemd-cat -t "${SYSTEMD_TOPIC}"
fi

References

[Read More]

Apple M1, terraform and golang

I was trying to apply a messy terraform config recently and kept running across an issue where the AWS provider would seemingly just get itself hung, using ~150% CPU. Killing it, deleting the terraform.tfstate and init/refresh/apply seemed to make it work sometimes. I thought I was having network connection issues, as it’d hang in random parts of a refresh or something like that.

The cause

Turns out it’s an issue with Rosetta 2 and golang fighting. There is more information in this comment from the Apple Developer-Ecosystem-Engineering account, where Rosetta’s handling of signals isn’t complete, but which has been fixed in recente versions of Rosetta.

[Read More]

Facebook Messenger weirdness on macOS

I’m stuck using Facebook Messenger, and they love trashing system performance in the browser, so I tried the “native” macOS app recently.

I’m not sure what I did, but after posting a sick medieval meme, it started reloading itself over and over. Kill, open, repeat - it just hung. Stuck cache? This is starting to turn into a theme

I figured deleting cache things worked last time, let’s try it again…

rm -rf "./Containers/com.facebook.archon/Data/Library/Application Support/Messenger/Partitions/*"

Opened, and it was OK again. Sigh.

[Read More]

IPA and the Stuck Cache

Went to grab a krb ticket today, and this was a fun error to get. I checked all the usual timestamp things… nothing wrong there.

[yaleman@ipaserver 15:41 ~]$ kinit
Password for [email protected]:
kinit: Clock skew too great while getting initial credentials

It wasn’t happening for anyone else, and it was working earlier, so that’s weird.

This was the error in the log files, that someone helpfully grabbed:

Dec 10 15:45:08 ipaserver.ipa.realm krb5kdc[7208](info): preauth (encrypted_timestamp) verify failure: Decrypt integrity check failed
Dec 10 15:45:08 ipaserver.ipa.realm krb5kdc[7208](info): AS_REQ (4 etypes {18 17 16 23}) 10.0.0.5: PREAUTH_FAILED: [email protected] for krbtgt/[email protected], Decrypt integrity check failed

I found a thread on the Kerberos mailing list about that error, which gave me some things to try.

[Read More]

I finally figured out my weird font issues in VS Code

I can’t remember when it started, but it was a while ago - Visual Studio Code started to show very strange font things when I have Editor: Render Whitespace turned on.

broken

This should look like…

working now

FInding the relevant thing to search for took… far too long. I ended up searching for “dot” and then clicking on random things in the Wikipedia page until I found Interpunct, and the Catalan usage of it…

[Read More]

Regarding My M1 MacBook's Battery

Got my M1 powered MacBook Pro 13" today. Haven’t plugged it in since taking it out of the box - has gone from 88% to 39% battery in about four hours of “DO ALL THE THINGS SETUP SYNC BACKUP”. The i7 sitting next to it hasn’t charged from ~20% to 100% in that time…

— James Hodgkinson (@yaleman43381258) December 1, 2020

[Read More]

PowerDNS All Data Was Not Consumed Message

This was … annoying today.

I’m playing with upgrading a PowerDNS instance and started getting All data was not consumed when doing queries against particular zones. Turns out, it was the space at the end of the SOA record, somehow something was adding that in…

# pdnsutil check-zone example.com
[Error] Following record had a problem: "example.com IN SOA ns1.example.net dns.example.net 2020092142 3600 7200 3600000 172800 "
[Error] Error was: All data was not consumed
Checked 26 records of 'example.com', 1 errors, 0 warnings.

# psql -h nsdb.example.com


powerdns=> select * from records where type='SOA' and name like '%isdnsworking%';
    id    | domain_id | name        | type |                      content                                         | ttl  | prio | change_date | disabled | ordername | auth
----------+-----------+-------------+------+----------------------------------------------------------------------+------+------+-------------+----------+-----------+------
 15122753 |   1557559 | example.com | SOA  | ns1.example.net dns.example.net 2020092142 3600 7200 3600000 172800  | 3600 |      |             | f        |           | t
(1 row)

powerdns=> update records set content='ns1.example.net dmain.netregistry.net 2020092142 3600 7200 3600000 172800' where type='SOA' and name like '%isdnsworking%' ;
UPDATE 1
powerdns=> select * from records where type='SOA' and name like '%isdnsworking%';
    id    | domain_id | name        | type |                     content                                         | ttl  | prio | change_date | disabled | ordername | auth
----------+-----------+-------------+------+---------------------------------------------------------------------+------+------+-------------+----------+-----------+------
 15122753 |   1557559 | example.com | SOA  | ns1.example.net dns.example.net 2020092142 3600 7200 3600000 172800 | 3600 |      |             | f        |           | t
(1 row)

powerdns=> \q
# pdnsutil check-zone example.com
Checked 26 records of 'example.com', 0 errors, 0 warnings.

… wow.

[Read More]

Battery Equivalence...

This was oddly hard to find…

The Energizer A544 is equivalent to the 4LR44, a 6 volt battery - which my Merlin garage door opener uses. It also replaces the 6V PX28A.

[Read More]

Raspberry Pi USB Boot 'USB-MSD Boot Requires Newer Software'

I was getting this error when trying to boot my Raspi4 8GB from USB:

USB-MSD boot requires newer software

The fix is to grab the latest firmware from the raspberrypi/firmware repository like so:

  1. git clone --depth 1 https://github.com/raspberrypi/firmware
  2. cd firmware/boot
  3. Mount the USB boot drive on my mac
  4. cp -R * /Volumes/boot
  5. Unmount the drive and put it into the Pi

This’ll copy the latest firmware (don’t delete any other files) and it should work.

[Read More]