feat(sterni/ingeborg/monitoring): send smartd warnings to IRC
Though netdata integrates smartd data it doesn't generate warnings like smartd does. It would be nice to have them go to IRC. The NixOS module for some reason has decided to implement its own very restricted notifications framework on top of the one that smartd provides dispatching to either mail (note that this is implemented in the NixOS module and doesn't use smartd's own support for this), wall(1) or some systemd mechanism. This is implemented in some shell script that can't be provided by the user. Luckily, the module is relatively small otherwise and we can easily inline the relevant service definitions and use our own script instead. Change-Id: I1e1ceff3c21a92ac42079c02813366671141b9b4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12969 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
This commit is contained in:
parent
767d6fdf78
commit
5dd66ab066
1 changed files with 31 additions and 12 deletions
|
|
@ -35,20 +35,39 @@ in
|
|||
}
|
||||
'';
|
||||
|
||||
# TODO(sterni): irc notifications (?)
|
||||
services = {
|
||||
smartd = {
|
||||
enable = true;
|
||||
autodetect = true;
|
||||
# Short self test every day 03:00
|
||||
# Long self test every tuesday 05:00
|
||||
defaults.autodetected = "-a -o on -s (S/../.././03|L/../../2/05)";
|
||||
extraOptions = [
|
||||
"-A"
|
||||
"/var/log/smartd/"
|
||||
];
|
||||
# Based on nixos/modules/services/monitoring/smard.nix which has a much
|
||||
# too specific smartd-notify.sh (and I'm too lazy to propose a redesign)
|
||||
systemd.services.smartd = {
|
||||
description = "S.M.A.R.T. Daemon";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "notify";
|
||||
ExecStart =
|
||||
let
|
||||
smartdNotify = pkgs.writeShellScript "smartd-notify.sh" ''
|
||||
${send-irc-msg} "smartd: $SMARTD_FAILTYPE($SMARTD_DEVICE): $SMARTD_MESSAGE"
|
||||
'';
|
||||
smartdConf = pkgs.writeText "smartd.conf" (
|
||||
# Short self test every day 03:00
|
||||
# Long self test every tuesday 05:00
|
||||
lib.concatMapStrings
|
||||
(d: ''
|
||||
${d} -m <nomailer> -M exec ${smartdNotify} -a -o on -s (S/../.././03|L/../../2/05)
|
||||
'')
|
||||
[ "DEFAULT" "DEVICESCAN" ]
|
||||
);
|
||||
in
|
||||
lib.concatStringsSep " " [
|
||||
"${pkgs.smartmontools}/sbin/smartd"
|
||||
"-A"
|
||||
"/var/log/smartd"
|
||||
"--no-fork"
|
||||
"--configfile=${smartdConf}"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
netdata = {
|
||||
enable = true;
|
||||
config = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue