lint check service
This commit is contained in:
parent
52c2852aa9
commit
6db4a527e6
@ -22,14 +22,14 @@ services=("syncthing@vincent",
|
||||
containers = ("pihole",)
|
||||
|
||||
|
||||
|
||||
class Service(object):
|
||||
def __init__(self, serviceName):
|
||||
self.name = serviceName
|
||||
|
||||
def is_active(self):
|
||||
cmd = "/usr/bin/systemctl"
|
||||
proc=subprocess.Popen([cmd,'is-active',self.name],stdout=subprocess.PIPE)
|
||||
proc = subprocess.Popen(
|
||||
[cmd, 'is-active', self.name], stdout=subprocess.PIPE)
|
||||
proc.communicate()
|
||||
rc = proc.returncode
|
||||
if rc == 0:
|
||||
@ -39,9 +39,11 @@ class Service(object):
|
||||
|
||||
def get_last_log(self):
|
||||
cmd = "/usr/bin/journalctl"
|
||||
proc=subprocess.check_output([cmd,'--lines=10','-q','-u',self.name])
|
||||
proc = subprocess.check_output(
|
||||
[cmd, '--lines=10', '-q', '-u', self.name])
|
||||
return proc.decode('UTF-8').split('\n')
|
||||
|
||||
|
||||
class Container(object):
|
||||
def __init__(self, containerName):
|
||||
self.name = containerName
|
||||
@ -49,7 +51,8 @@ class Container(object):
|
||||
def is_active(self):
|
||||
cmd = "/usr/bin/docker"
|
||||
try:
|
||||
proc=subprocess.check_output([cmd,'ps'],stderr=subprocess.STDOUT)
|
||||
proc = subprocess.check_output(
|
||||
[cmd, 'ps'], stderr=subprocess.STDOUT)
|
||||
except:
|
||||
proc = b''
|
||||
pass
|
||||
@ -69,7 +72,6 @@ if __name__ == '__main__':
|
||||
if (wait):
|
||||
time.sleep(15)
|
||||
|
||||
|
||||
for serviceName in services:
|
||||
serviceObj = Service(serviceName)
|
||||
if (serviceObj.is_active()):
|
||||
|
Loading…
Reference in New Issue
Block a user