about summary refs log tree commit diff
path: root/users/sterni/machines/ingeborg/monitoring.nix
diff options
context:
space:
mode:
Diffstat (limited to 'users/sterni/machines/ingeborg/monitoring.nix')
-rw-r--r--users/sterni/machines/ingeborg/monitoring.nix29
1 files 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"
             '';
           };
         };