Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Primitive bash http server to serve the status
#!/usr/bin/env bash
# Example:
# /tmp/status [8080] [40]
while true; do
PERCENT=`(cat ${1} | grep "Load:" | cut -d" " -f2) 2>/dev/null`
STATUS=`[[ -z "${PERCENT}" || "${PERCENT}" -gt ${3-79} ]] && echo "503" || echo "204"`
echo -e "HTTP/1.1 ${STATUS} OK\r\n\r\n" | nc -l --send-only -p ${2-8080} 1>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment