hp: website health checks

I wanted a program or a service to regularly check the health of my websites. Enter hp, a Unix-feeling command line program, and the antithesis of every fucking third-party cloud-hosted service designed towards a similar purpose.

$ go install go.growl.space/hp@latest


hp uses a plain text configuration file. Each line follows one of these formats.

http [method] [url] [code[,code]]
tls [addr] [duration]

From the docs:

For a http entry, hp reports an issue if the HTTP response status code for the URL does not match any of the specified codes. The method field specifies the HTTP request method (e.g. GET).

For a tls entry, hp reports an issue if the TLS certificate at the address expires sooner than the specified duration. Specifically, hp checks the “not after” date of the leaf TLS certificate sent by the server. The address is dialed over TCP. The duration value is parsed using time.ParseDuration.

Here’s an example configuration.

# personal website
http GET https://growl.space/ 200
http GET https://growl.space/posts/ 200
http GET https://growl.space/posts/on-go/ 200
http GET https://blog.growl.space/ 302

# go custom imports server
http GET https://go.growl.space/hp?go-get=1 200
http GET https://go.growl.space/hp/ 302

# check tls certificates
# 600h is around 25 days
tls growl.space:443 600h
tls go.growl.space:443 600h
tls littleroot.org:443 600h


The command outputs one line per input configuration entry, and a single summary line at the end.

The checks run concurrently.

$ cat hp.config.txt | hp
http GET https://growl.space/: 200: ok
http GET https://growl.space/posts/: 200: ok
http GET https://growl.space/posts/on-go/: 200: ok
http GET https://blog.growl.space/: 302: ok
http GET https://go.growl.space/hp?go-get=1: 200: ok
http GET https://go.growl.space/hp/: 302: ok
tls growl.space:443: remaining 2155h: ok
tls go.growl.space:443: remaining 2155h: ok
tls littleroot.org:443: remaining 2063h: ok
all: ok

If issues exist, the output will contain lines such as:

http GET https://growl.space/hp?go-get=1: bad status code: 500
tls growl.space:443: expires in 50h

Cron + hp

I run hp periodically with a cron job. For example, with OpenBSD 7.3 cron:

@daily		-n go/bin/hp -f hp.config.txt

If the cron implementation doesn’t support flags, such as -n, use hp’s own -s flag to avoid output when the program’s exit code is 0.

0 0 * * *	go/bin/hp -s -f hp.config.txt

These cron entries run hp daily and send mail with any issues found.