Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service status shows as false when the service name differs between systemctl and ps. #899

Open
narmatha291289 opened this issue Mar 22, 2024 · 0 comments

Comments

@narmatha291289
Copy link

Description:

Currently, the service list is retrieved using the systemctl command, and for fetching the running status and pids of a service, ps command is used, but the service name need not to be similar in both systemctl and ps. In that case, the service status is showing as false. Therefore, it is recommended to fetch the status and PIDs directly from the systemctl command to ensure accuracy.

Proposed Solution:

To mitigate this issue, it's suggested to solely rely on systemctl for fetching service statuses and associated PIDs. This ensures consistency and accuracy in reporting service statuses. Below is an updated command to fetch the PID list of a service using systemctl:

mainPid=$(systemctl show -p MainPID --value nginx)
pgrep -P $mainPid

Steps to Reproduce:

  1. Run the current script/command for fetching service statuses and PIDs.
  2. Observe discrepancies in service status reporting due to differing service names between systemctl and ps.
  3. Implement the proposed solution and verify the consistency in service status reporting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants