Last active
November 28, 2025 09:16
-
-
Save lhns/efb7f4efeda416cd7648f0dc77614035 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| (onrequest() { | |
| hddtemp /dev/sd* /dev/nvme*n* | jq -Rr 'sub("(?<device>.*?): (?<model>.*?): (?<value>\\d*).*"; "hw.temperature{hw.model=\"\(.model)\",system.device=\"\(.device)\"} \(.value)")' | |
| }; trap "exit 1" INT; while :; do content="$(onrequest; r=$?; echo /; exit "$r")"; { { echo -ne "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: $(printf %s "${content%/}" | wc -c)\r\n\r\n"; printf %s "${content%/}"; } | nc -l $(printf -- "$(nc -h 2>&1 | head -n 1 | grep -q Ncat && echo "%s %s" || echo "-s %s -p %s")" 127.0.0.1 8080) >/dev/null; } & wait; done) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment