summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/logf/default.nix
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2016-08-04 21:38:20 +0200
committerlassulus <lass@aidsballs.de>2016-08-04 21:38:20 +0200
commit37d53d7b2578106b3d2c53650bfad0e9d5489fbd (patch)
treee3c61342a43abc82ab00cc35eee591dc98ef69e6 /krebs/5pkgs/logf/default.nix
parent6696a9f09846adcc059a29566c949afc518b7574 (diff)
parent048986e09bfe9195ccd434c4c143d374db5488d2 (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'krebs/5pkgs/logf/default.nix')
-rw-r--r--krebs/5pkgs/logf/default.nix26
1 files changed, 18 insertions, 8 deletions
diff --git a/krebs/5pkgs/logf/default.nix b/krebs/5pkgs/logf/default.nix
index 246e4d954..d9eae0a4a 100644
--- a/krebs/5pkgs/logf/default.nix
+++ b/krebs/5pkgs/logf/default.nix
@@ -14,23 +14,27 @@ let
"5" = 255; # notice
"6" = 250; # info
"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 \
- 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 \
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: .,
@@ -40,9 +44,11 @@ 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 |
+ (env.LOGF_URGENT | fromjson | map("(\(.))") | join("|"))
+ as $urgent_regex |
def when(c; f): if c then f else . end;
@@ -88,10 +94,14 @@ 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 {
+ _SOURCE_REALTIME_TIMESTAMP: now | tostring | sub("[.]"; ""),
+ SYSLOG_IDENTIFIER: "logf/journalctl",
+ MESSAGE: .,
+ } |
[ p_time
, p_host