From ff42f5198f431b88e986349ecf01d341fa26661a Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Aug 2016 20:01:45 +0200 Subject: tv q: print $PWD/TODO --- tv/5pkgs/q/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tv/5pkgs/q/default.nix b/tv/5pkgs/q/default.nix index eeb600300..b19402fa4 100644 --- a/tv/5pkgs/q/default.nix +++ b/tv/5pkgs/q/default.nix @@ -190,4 +190,7 @@ pkgs.writeBashBin "q" '' (${q-thermal_zone}) & wait ${q-todo} + if [ "$PWD" != "$HOME" ]; then + (HOME=$PWD; ${q-todo}) + fi '' -- cgit v1.2.3 From 1e3dcaee3cf5b9f31e1e4510ab621629e249c434 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Aug 2016 20:06:08 +0200 Subject: logf: reduce redundant syntax --- krebs/5pkgs/logf/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/5pkgs/logf/default.nix b/krebs/5pkgs/logf/default.nix index 246e4d954..54b8a1877 100644 --- a/krebs/5pkgs/logf/default.nix +++ b/krebs/5pkgs/logf/default.nix @@ -23,9 +23,9 @@ pkgs.writeDashBin "logf" '' LOGF_PRIO_COLORS=$(cat "''${LOGF_PRIO_COLORS-${default-prio-colors}}") printf '%s\0' "$@" \ | ${pkgs.findutils}/bin/xargs -0 -P 0 -n 1 ${pkgs.writeDash "logf-remote" '' - target=$1 \ - target_host=$(echo "$1" | sed 's/^.*@//;s/\..*//') \ - exec 3>&1; + target=$1 + target_host=$(echo "$1" | sed 's/^.*@//;s/\..*//') + exec 3>&1 2>&1 1>&3 ssh "$target" -T \ -o PreferredAuthentications=publickey \ -o StrictHostKeyChecking=yes \ -- cgit v1.2.3 From 1bc62944e3e8eac639e2373c868a56c36bb67fb7 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Aug 2016 20:36:44 +0200 Subject: logf: add default color for undefined priority --- krebs/5pkgs/logf/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/5pkgs/logf/default.nix b/krebs/5pkgs/logf/default.nix index 54b8a1877..d73a1817a 100644 --- a/krebs/5pkgs/logf/default.nix +++ b/krebs/5pkgs/logf/default.nix @@ -14,6 +14,7 @@ let "5" = 255; # notice "6" = 250; # info "7" = 139; # debug + "-" = 005; # undefined priority }; in -- cgit v1.2.3 From a264c571f3b3bc096df11f84f8fd8c48ff591923 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Aug 2016 20:37:53 +0200 Subject: logf: survive non-JSON input --- krebs/5pkgs/logf/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/krebs/5pkgs/logf/default.nix b/krebs/5pkgs/logf/default.nix index d73a1817a..b575c1879 100644 --- a/krebs/5pkgs/logf/default.nix +++ b/krebs/5pkgs/logf/default.nix @@ -31,7 +31,7 @@ pkgs.writeDashBin "logf" '' -o PreferredAuthentications=publickey \ -o StrictHostKeyChecking=yes \ exec journalctl -af -n 0 -o json \ - | stdbuf -oL jq -Rf ${pkgs.writeJq "logf-remote-error.jq" '' + | stdbuf -oL jq -Rcf ${pkgs.writeJq "logf-remote-error.jq" '' { PRIORITY: "4", MESSAGE: ., @@ -41,7 +41,7 @@ pkgs.writeDashBin "logf" '' sleep 10m exec "$0" "$@" ''} \ - | ${pkgs.jq}/bin/jq -rf ${pkgs.writeJq "logf-filter.jq" '' + | ${pkgs.jq}/bin/jq -Rrf ${pkgs.writeJq "logf-filter.jq" '' (env.LOGF_HOST_COLORS | fromjson) as $host_colors | (env.LOGF_PRIO_COLORS | fromjson) as $prio_colors | @@ -93,6 +93,11 @@ pkgs.writeDashBin "logf" '' #| agsub("Start queue"; "\(.)\u0007" | col(fg(42); $prio_c)) | col($prio_c); + try fromjson catch { + _SOURCE_REALTIME_TIMESTAMP: now | tostring | sub("[.]"; ""), + SYSLOG_IDENTIFIER: "logf/journalctl", + MESSAGE: ., + } | [ p_time , p_host -- cgit v1.2.3 From 71a25b18755ea229be17ca01003a68471ff72760 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Aug 2016 20:46:11 +0200 Subject: logf: make urgency patterns configurable --- krebs/5pkgs/logf/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/krebs/5pkgs/logf/default.nix b/krebs/5pkgs/logf/default.nix index b575c1879..d9eae0a4a 100644 --- a/krebs/5pkgs/logf/default.nix +++ b/krebs/5pkgs/logf/default.nix @@ -16,12 +16,15 @@ let "7" = 139; # debug "-" = 005; # undefined priority }; + default-urgent = pkgs.writeJSON "logf.default-urgent.json" [ + ]; in pkgs.writeDashBin "logf" '' - export LOGF_HOST_COLORS LOGF_PRIO_COLORS + export LOGF_HOST_COLORS LOGF_PRIO_COLORS LOGF_URGENT LOGF_HOST_COLORS=$(cat "''${LOGF_HOST_COLORS-${default-host-colors}}") LOGF_PRIO_COLORS=$(cat "''${LOGF_PRIO_COLORS-${default-prio-colors}}") + LOGF_URGENT=$(cat "''${LOGF_URGENT-${default-urgent}}") printf '%s\0' "$@" \ | ${pkgs.findutils}/bin/xargs -0 -P 0 -n 1 ${pkgs.writeDash "logf-remote" '' target=$1 @@ -44,6 +47,8 @@ pkgs.writeDashBin "logf" '' | ${pkgs.jq}/bin/jq -Rrf ${pkgs.writeJq "logf-filter.jq" '' (env.LOGF_HOST_COLORS | fromjson) as $host_colors | (env.LOGF_PRIO_COLORS | fromjson) as $prio_colors | + (env.LOGF_URGENT | fromjson | map("(\(.))") | join("|")) + as $urgent_regex | def when(c; f): if c then f else . end; @@ -89,8 +94,7 @@ pkgs.writeDashBin "logf" '' as $prio_c | .MESSAGE | sub("\r$"; "") - | agsub("\\btv@nomic\\b"; "\(.)\u0007" | col(fg(219); $prio_c)) - #| agsub("Start queue"; "\(.)\u0007" | col(fg(42); $prio_c)) + | agsub($urgent_regex; "\(.)\u0007" | col(fg(219); $prio_c)) | col($prio_c); try fromjson catch { -- cgit v1.2.3 From 048986e09bfe9195ccd434c4c143d374db5488d2 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Aug 2016 21:36:44 +0200 Subject: make test: don't ssh if possible --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3857a2390..4fa5bc885 100644 --- a/Makefile +++ b/Makefile @@ -130,7 +130,12 @@ $(error bad method: $(method)) endif endif test: ssh ?= ssh +ifeq ($(target_user)@$(target_host),$(LOGNAME)@$(HOSTNAME)) +test: wrapper = exec +else +test: wrapper = $(ssh) $(target_user)@$(target_host) -p $(target_port) +endif test: populate - $(ssh) $(target_user)@$(target_host) -p $(target_port) \ + $(wrapper) \ $(command) --show-trace -I $(target_path) \ -A config.system.build.toplevel $(target_path)/stockholm -- cgit v1.2.3