From bbfffa3fdd1f508d204d89b5b69d29c82143f2f8 Mon Sep 17 00:00:00 2001 From: sterni Date: Sun, 17 Nov 2024 16:49:12 +0100 Subject: refactor(sterni/ingeborg/monitoring): simplify mkIrcMessager I want to add a warpper script to the mdmonitor program anyways, so there's not really a point in this. Change-Id: I92166bd44b54507b782a8d19b9676d91d8fa0f99 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12802 Tested-by: BuildkiteCI Reviewed-by: sterni Autosubmit: sterni --- users/sterni/machines/ingeborg/monitoring.nix | 29 +++++++++------------------ 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/users/sterni/machines/ingeborg/monitoring.nix b/users/sterni/machines/ingeborg/monitoring.nix index 6244bc5e88ce..f4a347047130 100644 --- a/users/sterni/machines/ingeborg/monitoring.nix +++ b/users/sterni/machines/ingeborg/monitoring.nix @@ -6,15 +6,11 @@ let builtins.replaceStrings [ ":" ] [ "" ] config.services.depot.irccat.config.tcp.listen; - mkIrcMessager = - { name - , msgExpr - }: - pkgs.writeShellScript name '' - set -euo pipefail - printf '%s %s\n' ${lib.escapeShellArg ircChannel} ${msgExpr} | \ - ${lib.getBin pkgs.netcat-openbsd}/bin/nc -N localhost ${irccatPort} - ''; + send-irc-msg = pkgs.writeShellScript "send-irc-msg" '' + set -euo pipefail + printf '%s %s\n' ${lib.escapeShellArg ircChannel} "$1" | \ + ${lib.getBin pkgs.netcat-openbsd}/bin/nc -N localhost ${irccatPort} + ''; netdataPort = 19999; in @@ -32,11 +28,9 @@ in # Since we have irccat we can wire up mdadm --monitor boot.swraid.mdadmConf = '' PROGRAM ${ - mkIrcMessager { - name = "mdmonitor-to-irc"; - # prog EVENT MD_DEVICE COMPONENT_DEVICE - msgExpr = ''"mdmonitor: $1($2''${3:+, $3})"''; - } + pkgs.writeShellScript "mdmonitor-to-irc" '' + ${send-irc-msg} "mdmonitor: $1($2''${3:+, $3})" + '' } ''; @@ -137,12 +131,7 @@ in esac echo "$0: INFO: sending message: $MSG" >&2 - ${ - mkIrcMessager { - name = "trivial-send-to-irc"; - msgExpr = "\"$1\""; - } - } "$MSG" + ${send-irc-msg} "$MSG" ''; }; }; -- cgit 1.4.1