Skip to content

Add new information methods (isActiveRaw, isEnabledRaw and show) #26

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

Merged
merged 4 commits into from
Apr 7, 2019

Conversation

deancsmith
Copy link

This PR adds three new methods to help get additional information about services. We are aiming to use this library to display information about several services on a web dashboard, with the potential management of these being a secondary concern.

To this end, I've added some additional info methods:

  • isActiveRaw(): retrieve the raw string output of the is-active command. We need this as we use some 'oneshot' services, which can be 'inactive' (as opposed to failed) under normal circumstances. Simply checking them to see if they are 'active', as the normal isActive() method does, is not enough for us: we need to raw response from the systemctl command.
  • isEnabledRaw(): retrieve the raw string output of the is-active command. We don't strictly need the output of this but I added it for completeness.
  • show(): retrieve the raw string output of the show command but parsing it to an array. We need some more detailed information like the time a 'oneshot' last ran, and potentially the ExecStart line to see the command actually run for debugging. This method takes the (extensive) output of the show command and makes it available to be easily consumed via a correctly keyed array of the output of the command.

Happy to make changes to the above to better conform with your library. I just quickly added these methods so we could access this additional systemd information.

@icanhazstring
Copy link
Owner

Hi. Thanks for using the lib and this PR. Will look over it asap. 👍

@icanhazstring icanhazstring merged commit e1a4dae into icanhazstring:1.x Apr 7, 2019
@icanhazstring
Copy link
Owner

icanhazstring commented Apr 7, 2019

Merged into 1.x and tagged with 1.0-rc2.
Are you using the current 1.x branch for your usage, or the currenty release 0.6.1?
Didn't notice you filed the PR against 1.x

@deancsmith
Copy link
Author

Thanks!

I only started looking at your library about an hour before I created the PR. I tried the 0.6.x branch but was having some issues/was looking for more info methods, so I switched to the newer 1.x branch. I still couldn't get the info that I needed, so I added these methods in a fork of the 1.x branch.

We may just keep using the fork in the short-term, as we are only using this info on a dev/debugging page at the moment. Once you get to 1 then we'll switch across, but don't worry about expediting that or backporting to 0.6.x on account of us.

FYI we are also using this on RHEL 7, which ships with a pretty old systemd (v219) (but I haven't noticed any negative effects of this).

@icanhazstring
Copy link
Owner

FYI we are also using this on RHEL 7, which ships with a pretty old systemd (v219) (but I haven't noticed any negative effects of this).

The major difference I came upon is the format of on_calendar setting for timer.
But since your are not creating a unit with this lib. You won't encounter any problems ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants