Re: hint to know the state of the service using function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






From: Cristian Rodríguez <crrodriguez@xxxxxxxxxxxx>
Sent: Friday, August 23, 2024 11:11 PM
To: Rajmohan. R <Rajmohan.R@xxxxxxxx>
Cc: systemd-devel <systemd-devel@xxxxxxxxxxxxxxxxxxxxx>
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@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.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.


 
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.

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux