[systemd-devel] hint to know the state of the service using function
Rajmohan. R
Rajmohan.R at kpit.com
Sat Aug 24 05:11:58 UTC 2024
________________________________
From: Cristian Rodríguez <crrodriguez at opensuse.org>
Sent: Friday, August 23, 2024 11:11 PM
To: Rajmohan. R <Rajmohan.R at kpit.com>
Cc: systemd-devel <systemd-devel at lists.freedesktop.org>
Subject: Re: [systemd-devel] hint to know the state of the service using function
Caution: This email originated from outside of the KPIT. Do not click links or open attachments unless you recognize the sender and know the content is safe.
On Fri, Aug 23, 2024 at 11:51 AM Rajmohan. R <Rajmohan.R at kpit.com<mailto:Rajmohan.R at kpit.com>> 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.c
index 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, UnitNotifyFlag
if (!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..
I had already raised a PR for the above change in https://github.com/systemd/systemd/pull/32430 PR.
But got review saying intense logging is not required and also timestamps can be queried.
This change will inform that the service name is in which state from inactive_exit while in the target system, which is logged in journal file for later debugging.
Shall i raise new PR only for this change by changing warning to debug.
[https://opengraph.githubassets.com/15c897f7dec97b7ede6d690084794d8249085b62791f0602284b0bef9c3ef82c/systemd/systemd/pull/32430]<https://github.com/systemd/systemd/pull/32430>
Patches 2 upstream systemd by rajmohanrgithub · Pull Request #32430 · systemd/systemd<https://github.com/systemd/systemd/pull/32430>
Message from commits is given below: systemd: Add more logs for boot procedure analysis systemd-analyze: Add svg scaling options systemd: set suid_dumpable to "suidssafe" mount: Remove fi...
github.com
This message contains information that may be privileged or confidential and is the property of the KPIT Technologies Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Technologies Ltd. does not accept any liability for virus infected mails.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20240824/e10ff389/attachment-0001.htm>
More information about the systemd-devel
mailing list