If someone/something shuts down the machine I am logged in to via ssh, I usually get just
Shared connection to 2001:db8::1 closed.
I would like to distinguish this from local or network issues:
Power button (/dev/input/..) pressed, shutting down now.
Critical battery action: shutting down now.
Immediate shutdown initiated by user betty, no wall message provided.
Where can I hook into systemd to enable a detailed broadcast while handling power buttons?
Partial solutions:
- A systemd unit hooked to run before sshd quits can report the ordinary shutdown procedure, but cannot reliably tell the trigger (
grep
ing for relevant journal entries works somewhat okay). - When reasonably sure that a shutdown should not be attempted in the first place, I can use
systemd-inhitibit
instead, letting the other party figure out coordinating the shutdown with me. - I know
wall
still works in modern times:shutdown time "wall message"
does broadcast to allmesg y
users. I could not find the place to enforce a default value.