On Fri, Aug 23, 2024 at 11:51 AM Rajmohan. R <Rajmohan.R@xxxxxxxx> wrote:
Hi,Below is the change related to logging of the units (service) while changing the state [in]active_[exit/enter].
I did not get any hint from source code, to know the state change using function, without querying the target system through CLI.Could someone from the forum help in providing a hint on how to get the state of the services without querying through CLI.
Instead of below changes, is there any alternative modification i can do to know the state of the service.
diff --git a/src/core/unit.c b/src/core/unit.cindex c406bb7ab2..e6ad9b3fbf 100644--- a/src/core/unit.c+++ b/src/core/unit.c@@ -2497,15 +2497,31 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlagif (!MANAGER_IS_RELOADING(m)) {dual_timestamp_get(&u->state_change_timestamp);- if (UNIT_IS_INACTIVE_OR_FAILED(os) && !UNIT_IS_INACTIVE_OR_FAILED(ns))+ if (UNIT_IS_INACTIVE_OR_FAILED(os) && !UNIT_IS_INACTIVE_OR_FAILED(ns)) {u->inactive_exit_timestamp = u->state_change_timestamp;- else if (!UNIT_IS_INACTIVE_OR_FAILED(os) && UNIT_IS_INACTIVE_OR_FAILED(ns))+ log_warning("sd: u=%s, inactive_exit="USEC_FMT,+ u->id, u->inactive_exit_timestamp.monotonic);
A patch that does this may be acceptable if you file a PR and use the debug level.. using the warning level for this does not fly..