diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-14 22:42:12 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-14 22:42:12 +0300 |
| commit | a911c4e690608a9a8430e928fe1853f4a217fbda (patch) | |
| tree | 598d2775b7ed1c757b96f3dbd10ad0c6caad2f21 /frontends/scripts | |
| parent | 2a81b54c59ff937f66d42bf7aa625c5e30d62321 (diff) | |
frontends: daily goprecords uptimed upload for fishfinger and blowfish.
Add POSIX sh script template deployed to /usr/local/bin/goprecords-upload.sh,
invoked from /etc/daily.local. Rex task goprecords_upload installs curl, renders
per-host script from geheim secrets/etc/goprecords/<host>.token, and hooks
commons. Document token layout and kubectl key creation in README.
Made-with: Cursor
Diffstat (limited to 'frontends/scripts')
| -rw-r--r-- | frontends/scripts/goprecords-upload.sh.tpl | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/frontends/scripts/goprecords-upload.sh.tpl b/frontends/scripts/goprecords-upload.sh.tpl new file mode 100644 index 0000000..4770f1e --- /dev/null +++ b/frontends/scripts/goprecords-upload.sh.tpl @@ -0,0 +1,51 @@ +#!/bin/sh +set -e +HOST="<%= $goprecords_host %>" +BASE_URL="https://goprecords.f3s.buetow.org" +TOKEN="<%= $goprecords_token %>" +PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:${PATH}" + +upload() { + kind=$1 + file=$2 + if [ ! -f "$file" ]; then + echo "goprecords-upload: skip $kind (no $file)" >&2 + return 0 + fi + curl -fsS -X PUT --data-binary "@${file}" \ + -H "Authorization: Bearer ${TOKEN}" \ + "${BASE_URL}/upload/${HOST}/${kind}" +} + +records_path=/var/db/uptimed/records +if [ -f /var/spool/uptimed/records ]; then + records_path=/var/spool/uptimed/records +fi + +tmp=$(mktemp) +trap 'rm -f "$tmp"' 0 INT TERM HUP + +upload records "$records_path" + +if command -v uprecords >/dev/null 2>&1; then + uprecords -a -m 100 >"$tmp" + upload txt "$tmp" + uprecords -a | grep '^->' >"$tmp" || true + if [ -s "$tmp" ]; then + upload cur.txt "$tmp" + fi +fi + +if [ -r /etc/os-release ]; then + upload os.txt /etc/os-release +else + uname -a >"$tmp" + upload os.txt "$tmp" +fi + +if [ -r /var/run/dmesg.boot ]; then + upload cpuinfo.txt /var/run/dmesg.boot +else + sysctl hw.model hw.ncpu hw.machine >"$tmp" 2>/dev/null || uname -a >"$tmp" + upload cpuinfo.txt "$tmp" +fi |
