systemd/pystemd

AttributeError: 'SDInterface' object has no attribute 'GetProcesses'

dabcoder opened this issue · 8 comments

import pystemd
from pystemd.systemd1 import Unit

unit = Unit(b'ssh.service') . # tried with some other units too
unit.load()
unit.Service.GetProcesses()

I am getting:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'SDInterface' object has no attribute 'GetProcesses'

Am I missing anything there?

nope you are doing it right, here is my output

In [1]: c = pystemd.systemd1.Unit('crond.service', _autoload=True)

In [2]: c.Service.GetProcesses()
Out[2]: 
[(b'/system.slice/crond.service',
  26869,
  b'/usr/sbin/crond -n -m/usr/us/ops/scripts/mailops/cron_output_handler'),
 ...
...
 (b'/system.slice/crond.service', 1696433, b'/bin/sleep 282')]

Does GetProcesses exists in your version of systemd?, you can try to introspect the bus object (using busctl) to find if GetProcesses exists..

what version of systemd are you running?

what version of systemd are you running?

systemctl --version
systemd 237

busctl list doesn't give any indications with regards to GetProcesses. Is it due to a systemd version issue?

@aleivag I kept looking into this but given that GetProcesses does not exist in some less recent versions of systemd, would it make sense to add a quick comment in the README to clarify this point (I can issue a PR for that if so)?
I also tried unsuccessfully to use busctl to gather more info, so if you have any more specific info to share on this topic, that'd be great (can also include that info in the README if it makes sense to add it).

Thanks!

kfix commented

GetProcesses was added in systemd/systemd@291d565a
github says its in the v230 tag ...

kfix commented

oh it's "GetUnitProcesses"

kfix commented

looks like GetProcesses wasn't allowed until v238 by systemd/systemd@a6011d1

Thanks for following up on that. I can issue a PR to add this as a comment in the README maybe.

Closing as the PR was merged.