mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
add uptime
This commit is contained in:
parent
4add88a5a0
commit
254f6421a5
2 changed files with 12 additions and 1 deletions
|
@ -436,6 +436,11 @@ action_dict = {
|
||||||
'help' : _("Ifconfig"),
|
'help' : _("Ifconfig"),
|
||||||
'action' : 'store_true',
|
'action' : 'store_true',
|
||||||
},
|
},
|
||||||
|
'-u' : {
|
||||||
|
'full' : '--uptime',
|
||||||
|
'help' : _("Show Uptime"),
|
||||||
|
'action' : 'store_true',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import psutil
|
import psutil
|
||||||
|
from datetime import datetime, timedelta
|
||||||
from psutil._compat import print_
|
from psutil._compat import print_
|
||||||
|
|
||||||
def bytes2human(n):
|
def bytes2human(n):
|
||||||
|
@ -42,8 +43,11 @@ def ifconfig():
|
||||||
ip = output[(output.find('Bcast')-15):(output.find('inet')+22)]
|
ip = output[(output.find('Bcast')-15):(output.find('inet')+22)]
|
||||||
print 'MAC: ' + mac + ' IP: ' +ip
|
print 'MAC: ' + mac + ' IP: ' +ip
|
||||||
else:
|
else:
|
||||||
return 'MAC NOT FOUND!'
|
print 'MAC NOT FOUND!'
|
||||||
|
|
||||||
|
def uptime():
|
||||||
|
uptime = datetime.now() - datetime.fromtimestamp(psutil.BOOT_TIME)
|
||||||
|
print "Uptime: %s" % (str(uptime).split('.')[0])
|
||||||
|
|
||||||
def monitor_info(args, connections):
|
def monitor_info(args, connections):
|
||||||
if args['memory'] == True:
|
if args['memory'] == True:
|
||||||
|
@ -54,3 +58,5 @@ def monitor_info(args, connections):
|
||||||
check_disk()
|
check_disk()
|
||||||
elif args['ifconfig'] == True:
|
elif args['ifconfig'] == True:
|
||||||
ifconfig()
|
ifconfig()
|
||||||
|
elif args['uptime'] == True:
|
||||||
|
uptime()
|
||||||
|
|
Loading…
Add table
Reference in a new issue