diff --git a/nixos/module/hectic/hardware/lenovo-ideapad-15arh7.nix b/nixos/module/hectic/hardware/lenovo-ideapad-15arh7.nix index 502e082..576f252 100644 --- a/nixos/module/hectic/hardware/lenovo-ideapad-15arh7.nix +++ b/nixos/module/hectic/hardware/lenovo-ideapad-15arh7.nix @@ -12,6 +12,16 @@ cfg = config.hectic.hardware.lenovo-ideapad-15arh7; hasDisko = false; in { + # FIXME: FUCK + #imports = [ + # "${inputs.nixos-hardware}/common/cpu/amd" + # "${inputs.nixos-hardware}/common/cpu/amd/pstate.nix" + # "${inputs.nixos-hardware}/common/gpu/amd" + # "${inputs.nixos-hardware}/common/gpu/nvidia/prime-sync.nix" + # "${inputs.nixos-hardware}/common/pc/laptop" + # "${inputs.nixos-hardware}/common/pc/laptop/ssd" + #]; + options.hectic.hardware.lenovo-ideapad-15arh7 = { enable = lib.mkEnableOption "Enable lenovo-legion hardware configurations"; swapSize = lib.mkOption { @@ -35,16 +45,6 @@ in { }; config = lib.mkIf cfg.enable { - zlaupa = 12; - imports = [ - "${inputs.nixos-hardware}/common/cpu/amd" - "${inputs.nixos-hardware}/common/cpu/amd/pstate.nix" - "${inputs.nixos-hardware}/common/gpu/amd" - "${inputs.nixos-hardware}/common/gpu/nvidia/prime-sync.nix" - "${inputs.nixos-hardware}/common/pc/laptop" - "${inputs.nixos-hardware}/common/pc/laptop/ssd" - ]; - /* common */ hardware.nvidia = { modesetting.enable = true; diff --git a/package/sentinèlla/default.nix b/package/sentinèlla/default.nix index 4ffb446..0df6393 100644 --- a/package/sentinèlla/default.nix +++ b/package/sentinèlla/default.nix @@ -1,4 +1,4 @@ -{ symlinkJoin, writeTextFile, socat, dash, hectic, curl, gawk }: +{ symlinkJoin, writeTextFile, socat, dash, hectic, curl, gawk, jq }: let shell = "${dash}/bin/dash"; bashOptions = [ @@ -30,7 +30,7 @@ let sentinel = hectic.writeShellApplication { inherit shell bashOptions; name = "sentinel"; - runtimeInputs = [ hectic.shellplot curl ]; + runtimeInputs = [ hectic.shellplot curl jq ]; text = '' ${builtins.readFile ./log.sh} diff --git a/package/sentinèlla/router.sh b/package/sentinèlla/router.sh index 7460434..804099d 100644 --- a/package/sentinèlla/router.sh +++ b/package/sentinèlla/router.sh @@ -3,6 +3,7 @@ # router.sh — POSIX sh HTTP backend (for socat) # usage: socat -T5 -t5 TCP-LISTEN:${port},reuseaddr,fork EXEC:"dash ${currentfile}" # Routes: +# GET / -> {"status":...,"disk":...} # GET /status -> check $URLS (0/0 if unset) # GET /disk -> check $VOLUMES (all if unset) # Env: @@ -14,6 +15,10 @@ : "${TIMEOUT:=5}" : "${VOLUMES:=$(df -P | awk 'NR>1{print $6}')}" +route_summary() { + printf '%s' '{"status":'"$(route_status)"',"disk":'"$(route_disk)"'}' +} + route_status() { if [ -z "${URLS:-}" ]; then printf '{"checks":[],"summary":{"total":0,"ok":0}}' @@ -103,8 +108,9 @@ tmp=$(mktemp) || exit 1 trap 'rm -f "$tmp"' EXIT INT HUP case "$req" in - "GET /status "*) route_status >"$tmp"; status='200 OK'; ctype='application/json' ;; - "GET /disk "*) route_disk >"$tmp"; status='200 OK'; ctype='application/json' ;; + "GET / "*) route_summary >"$tmp"; status='200 OK'; ctype='application/json' ;; + "GET /status "*) route_status >"$tmp"; status='200 OK'; ctype='application/json' ;; + "GET /disk "*) route_disk >"$tmp"; status='200 OK'; ctype='application/json' ;; *) printf 'Not found\n' >"$tmp"; status='404 Not Found'; ctype='text/plain' ;; esac diff --git a/package/sentinèlla/sentinel.sh b/package/sentinèlla/sentinel.sh index 683ea98..9945dd8 100644 --- a/package/sentinèlla/sentinel.sh +++ b/package/sentinèlla/sentinel.sh @@ -75,6 +75,10 @@ list_failures() { } # --- main loop --- + +# NOTE: remove temp response body on any exit +trap 'rm -f "$tmpb" 2> /dev/null' EXIT INT HUP + while :; do log info "pooling ${WHITE}${POLLING_INTERVAL_SEC}${NC} sec" i=1 @@ -83,7 +87,7 @@ while :; do [ -n "${srv:-}" ] || break tok=$(get_csv "$TOKENS" "$i") || tok="-" - url="${srv%/}/status" + url="${srv%/}" auth_h="" [ "${tok}" != "-" ] && [ -n "${tok}" ] && auth_h="-H Authorization: Basic\ $tok"