Created services file

This commit is contained in:
Stefan Weijers 2021-07-25 16:00:30 +02:00
parent f4a168a3a5
commit 6947bb4f8c
2 changed files with 24 additions and 2 deletions

View File

@ -15,11 +15,10 @@ def generateBar(percentage):
bar = bar + bcolors.UNUSED + '='*(barWidth - no_used)
return bar + bcolors.RESET + ']'
mountpoints = ['/', '/dev']
cmd = 'df -h '
# Generate command to be executed
for mount in mountpoints:
for mount in env.mountpoints:
cmd = cmd + mount + ' '
du = os.popen(cmd).read() # Execute command on system

23
services.py Normal file
View File

@ -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')))