Created services file
This commit is contained in:
parent
f4a168a3a5
commit
6947bb4f8c
|
|
@ -15,11 +15,10 @@ def generateBar(percentage):
|
||||||
bar = bar + bcolors.UNUSED + '='*(barWidth - no_used)
|
bar = bar + bcolors.UNUSED + '='*(barWidth - no_used)
|
||||||
return bar + bcolors.RESET + ']'
|
return bar + bcolors.RESET + ']'
|
||||||
|
|
||||||
mountpoints = ['/', '/dev']
|
|
||||||
cmd = 'df -h '
|
cmd = 'df -h '
|
||||||
|
|
||||||
# Generate command to be executed
|
# Generate command to be executed
|
||||||
for mount in mountpoints:
|
for mount in env.mountpoints:
|
||||||
cmd = cmd + mount + ' '
|
cmd = cmd + mount + ' '
|
||||||
|
|
||||||
du = os.popen(cmd).read() # Execute command on system
|
du = os.popen(cmd).read() # Execute command on system
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
import os
|
||||||
|
from config import bcolors,env
|
||||||
|
|
||||||
|
def genLine(name, status, time):
|
||||||
|
if status == 'active': return '[' + name + '] [' + bcolors.EMPTY + '✓' + bcolors.RESET + '] [' + bcolors.EMPTY + time + bcolors.RESET + ']'
|
||||||
|
if status == 'inactive': return '[' + name + '] [' + bcolors.FULL + '✓' + bcolors.RESET + '] [' + bcolors.FULL + 'N/A' + bcolors.RESET + ']'
|
||||||
|
|
||||||
|
statuscmd = 'systemctl is-active {}'
|
||||||
|
timecmd = 'systemctl status {} | grep -Po \".*; \K(.*)(?= ago)\"'
|
||||||
|
|
||||||
|
statuslist = {}
|
||||||
|
timelist = {}
|
||||||
|
|
||||||
|
srv = env.services.keys()
|
||||||
|
|
||||||
|
for s in srv:
|
||||||
|
statuslist.update({s : os.popen(statuscmd.format(s)).read()})
|
||||||
|
timelist.update({s : os.popen(timecmd.format(s)).read()})
|
||||||
|
|
||||||
|
print("Services running:")
|
||||||
|
|
||||||
|
for s in srv:
|
||||||
|
print(genLine(env.services[s], statuslist[s].strip('\n'), timelist[s].strip('\n')))
|
||||||
Loading…
Reference in New Issue