[systemd-devel] Antw: [EXT] Re: [systemd‑devel] Q: Perform action for reboots happen too frequently?

Ulrich Windl Ulrich.Windl at rz.uni-regensburg.de
Thu Feb 17 09:50:19 UTC 2022


>>> Lennart Poettering <lennart at poettering.net> schrieb am 16.02.2022 um 18:17
in
Nachricht <Yg0xkENt8XNvo+y4 at gardel-login>:
> On Mi, 16.02.22 14:09, Ulrich Windl (Ulrich.Windl at rz.uni‑regensburg.de)
wrote:
> 
>> Hi!
>>
>> I wonder: Is it possible with systemd to detect multiple reboots
>> within a specific time interval, and react, like executing some
>> systemctl command (that is expected to "improve" things)?  With
>> "reboots" I'm mainly thinking of unexpected boots, not so much the
>> "shutdown ‑r" commands, but things like external resets, kernel
>> panics, watchdog timeouts, etc.
> 
> The information why a system was reset is hard to get. Some watchdog
> hw will tell you if it was recently triggered, and some expensive hw
> might log serious errors to the acpi pstore stuff, but it's all icky
> and lacks integration.

Lennart,

you got me wrong: I don't want to filter on the reasons of the (re)boot, but I
just wanted to rule out any possible solution that stores information during an
orderly shutdown/reboot ;-)

> 
> A safe approach would probably to instead track boots where the root
> fs or so is in dirty state. Pretty much all of today's file systems
> track that.

In the past (when there are a few logins only) I would have been tempted to
use "last" to grep for boots, but if there are many (automated) logins, those
boots may be "rolled out" and thus won't be counted possibly.

> 
> It sounds like an OK feature to add to the systemd root fs mount logic
> to check for the dirty flag before doing that and then using that is
> hint to boot into a target other than default.target that could then
> apply further policy (and maybe then go on to enter default.target).
> 
> TLDR: nope, this does not exist yet, but parts of it sound like
> worthwile feature additions to systemd.

Something very primitive:
a) Increment some counter on every boot, and reset that counter after some
time.
b) Check the counter and if it is >= some threshold, execute a one-shot
command

Could systemd help with a) and b)?

Regards,
Ulrich





> 
> Lennart
> 
> ‑‑
> Lennart Poettering, Berlin





More information about the systemd-devel mailing list