Open alfredodeza opened 5 years ago
Dunno whether you want to go down this route, but we can get the information from dbus
import dbus
sysbus = dbus.SystemBus()
systemd1 = sysbus.get_object('org.freedesktop.systemd1',
'/org/freedesktop/systemd1')
manager = dbus.Interface(systemd1, 'org.freedesktop.systemd1.Manager')
jobs = manager.ListUnits()
running = [job for job in jobs if str(job[4]) == 'running']
running_services = [job for job in running if str(job[0]).endswith('.service')]
for job in running_services:
print(job) # dbus.Struct
@ktdreyer is this dbus
a package?
The thing here is we just want to see what IDs are running, so we aren't really like "parsing" but more like checking if ceph-osd
is in a line and then getting the ID
Right, it's the "python3-dbus" package on Fedora, https://dbus.freedesktop.org/doc/dbus-python/tutorial.html
Must parse output from: