Skip to content

Instantly share code, notes, and snippets.

@Quar
Created November 10, 2017 19:26
Show Gist options
  • Save Quar/58c9b7f5b993afd213a983468cba40d7 to your computer and use it in GitHub Desktop.
Save Quar/58c9b7f5b993afd213a983468cba40d7 to your computer and use it in GitHub Desktop.
Compare List-Serice-Status difference between SystemV and SystemD
#!/usr/bin/env python3
import subprocess as sp
import shlex
CMD_SYSTEMV_LIST="""
service --status-all | cut -d']' -f2 | xargs -n 1
"""
CMD_SYSTEMD_LIST="""
systemctl list-units --type=service | cut -d' ' -f1
"""
procv = sp.Popen(CMD_SYSTEMV_LIST
, stdout = sp.PIPE, shell=True)
procd = sp.Popen(CMD_SYSTEMD_LIST
, stdout = sp.PIPE, shell=True)
outv, errv = procv.communicate()
outd, errd = procd.communicate()
if errv or errd:
print('errv:', errv, sep="\n")
print('errd:', errd, sep="\n")
os.exit(1)
vset = set(outv.decode().split())
dset = set(outd.decode().split())
print('==> Following service listed in SystemV are not listed in SystemD:')
print(*[ v for v in vset
if all([not (v.lower() in d.lower()) for d in dset])]
, sep="\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment