You are not logged in.

#1 2020-07-25 10:32:55

Yann
Member
Registered: 2017-11-23
Posts: 235

Kernel trigger command multi type event

Hi everyone,
My question is not easy to formulate and I think pretty vaste. I would like to get more control on my system and be able to run a command to lots of different type of kernel events.
In my understanding, all kind of event (file system, hardware, volume, processor, network, disks, etc.) have to pass and be treated by the kernel. Then the kernel does different things such as communicating the event to a dedicated daemon such as udev.

So, how can I get my personnel commands to be triggered at any kind of os event?

  • Do I have to deal with lots of different daemons such as udev or systemd ? If it's the case, which are the daemons I have to deal with ?

  • Is there one daemon that can make me record all my personnel commands such as the Event Tracing utility ?

Thanks for your time.


all different - all equal

Offline

#2 2020-07-25 12:21:01

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: Kernel trigger command multi type event

Try to formulate a concrete example of what you want to do. What do you intend to trigger on which event and why? Open ended questions can only have open ended answers and that answer for what is best here is "it depends".

The subsystem you want to deal with on hardware device events "in general" is udev:  https://wiki.archlinux.org/index.php/Udev

There are a few events that can also not end up in an explicit udev invocation, like e.g. headphone toggles for sound cards that's usually done via ACPI and can be handled and reacted to with acpid: https://wiki.archlinux.org/index.php/Acpid

If you want to have logs from certain kind of events properly configuring the audit framework might help: https://wiki.archlinux.org/index.php/Audit_framework and/or leveraging the journal by running your commands as systemd services (... there's systemd-run for invoking commands on-the-fly with auto-generated volatile services that might be useful for this)

Last edited by V1del (2020-07-25 12:23:58)

Offline

#3 2020-07-25 12:53:09

Yann
Member
Registered: 2017-11-23
Posts: 235

Re: Kernel trigger command multi type event

Hi V1del, Thanks for the answer.
Well, in the first time, I use i3wm with i3bar and have coded a process checking, in a loop model, for changes of all kinds:

  • Network state (ethernet, wireless)

  • Processors states

  • Memory states (RAM and swap)

  • My 2 main disk partitions

  • Sound volume

  • Bluetooth

  • My IOT devices states

  • Date and hour

This process does stuff when changes and results with a display update in my bar (i3) and/or show a notification.
For a few time now I realized that using a loop to do that is not the good way and it will be much faster, lighter and accurate to be informed of any of these changes directly from the kernel when it noticed the change. Then I will be able to directly call a script that will directly perform all the actions I want ending by updating the i3 bar.

I am already using udev for the lid and hdmi management.

So, with the udev, acpid and systemd daemons I will be able to trigger a process doing what I want for any of the event I specified ? So, there is no one daemon, or process I can use to manage all of this? Are there others daemons that I should look for some event not managed by the ones mentioned ?


all different - all equal

Offline

#4 2020-08-02 19:00:24

Yann
Member
Registered: 2017-11-23
Posts: 235

Re: Kernel trigger command multi type event

I already use udev for lid and power management. Can someone answer my last question? Would be very useful to me.


all different - all equal

Offline

#5 2020-08-03 09:02:28

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: Kernel trigger command multi type event

There's unlikely a single daemon that manages all of these distinct and often unrelated things in one utility. You are probably also not going to get kernel events about memory changes, I'd say doing your own loop on this is what most software does and should be a sufficient way for getting at the relevant information.

Offline

#6 2020-08-03 09:52:54

Yann
Member
Registered: 2017-11-23
Posts: 235

Re: Kernel trigger command multi type event

Thanks V1del,
So your advice is to use udev, acpid and systemd for the events I can manage from them. And keep my current loop for the events I can't manage from kernel/daemons. An hybrid solution finally?


all different - all equal

Offline

Board footer

Powered by FluxBB