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