nix-git/modules/journalwatch.nix

106 lines
3.3 KiB
Nix
Raw Normal View History

{ config, pkgs, ... }:
{
# Write to Systemd Journal:
# echo 'hello' | systemd-cat -p emerg
# echo 'hello' | systemd-cat -t someapp -p emerg
# View Systemd Journal.
# Filter by app:
# journalctl -b -t someapp
# Filter by priority:
# journalctl -b -p 5
# Manually execute journalwatch timer:
# sudo systemctl start journalwatch.service
# Find a message and view its details
# journalctl -b -p5 -o json-pretty
# Then press "/" and enter a pattern, then press "Enter".
assertions = [{
assertion = config.services.opensmtpd.enable;
message = "journalwatch requires a configured sendmail MTA, see sendmail-mta.nix.";
}];
services.journalwatch = {
enable = true;
# TODO: Same as configured by sendmail MTA.
mailFrom = "langbein@mail.de";
mailTo = "daniel+journalwatch@systemli.org";
#interval = "hourly";
# Lowest priority of message to be considered. A value between 7 (“debug”), and 0 (“emerg”). Defaults to 6 (“info”). If you dont care about anything with “info” priority, you can reduce this to e.g. 5 (“notice”) to considerably reduce the amount of messages without needing many filterBlocks.
priority = 5;
# Default patterns: https://github.com/The-Compiler/journalwatch/blob/363725ac4b8aa841d87654fa8a63403a59ad1275/journalwatch.py#L71
# If the value of `match` starts and ends with a slash, it is interpreted as a regular expression, if not, it's an exact match.
# `filters` are always regular expressions.
# All regular expressions have to match the full string!
filterBlocks = [
{
filters = ''
.*
'';
match = "_SYSTEMD_UNIT = bluetooth.service";
}
{
filters = ''
.*
'';
match = "_SYSTEMD_UNIT = cups.service";
}
{ # If the user `yoda` runs a command with `sudo`.
filters = ''
\s+yoda : TTY=pts/7 ; PWD=/.+ ; USER=root ; COMMAND=/.+
'';
match = "SYSLOG_IDENTIFIER = sudo";
}
{
filters = ''
The system will suspend now!
'';
match = "_SYSTEMD_UNIT = systemd-logind.service";
}
{
filters = ''
Reexecuting.
finished switching to system configuration /nix/store/.+-nixos-system-.+-[0-9]+\.[0-9]+pre-git
'';
match = "_SYSTEMD_UNIT = user@0.service";
}
{
filters = ''
Reexecuting.
finished switching to system configuration /nix/store/.+-nixos-system-.+-[0-9]+\.[0-9]+pre-git
'';
match = "_SYSTEMD_UNIT = user@1000.service";
}
{
filters = ''
Reloading rules
Collecting garbage unconditionally...
Loading rules from directory /.+
Finished loading, compiling and executing [0-9]+ rules
'';
match = "_SYSTEMD_UNIT = polkit.service";
}
{ # yodaTux
filters = ''
.+ error name="org\.bluez\.MediaEndpoint1\.Error\.NotImplemented" .+
'';
match = "_SYSTEMD_USER_UNIT = dbus.service";
}
{ # yodaTux
filters = ''
ACPI: FW issue: working around C-state latencies out of order
# Kernel WiFi driver bug.
iwlwifi 0000:01:00.0: Unhandled alg: 0x707
'';
match = "SYSLOG_IDENTIFIER = kernel";
}
];
};
}