Update the uptime command to display real uptime of the honeypot, and zero

load. This closes issue #47

Also added a small change to ps output.


git-svn-id: https://kippo.googlecode.com/svn/trunk@217 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
desaster
2012-04-08 16:41:34 +00:00
parent ace3015574
commit 0eaf51c48e
3 changed files with 48 additions and 6 deletions

View File

@@ -52,5 +52,33 @@ def tail(the_file, lines_2find=20):
return line_list[-lines_2find:]
#we read at least 21 line breaks from the bottom, block by block for speed
#21 to ensure we don't get a half line
# Gives a human-readable uptime string
# Thanks to http://thesmithfam.org/blog/2005/11/19/python-uptime-script/
# (modified to look like the real uptime command)
def uptime(total_seconds):
total_seconds = float(total_seconds)
# Helper vars:
MINUTE = 60
HOUR = MINUTE * 60
DAY = HOUR * 24
# Get the days, hours, etc:
days = int(total_seconds / DAY)
hours = int((total_seconds % DAY) / HOUR)
minutes = int((total_seconds % HOUR) / MINUTE)
# 14 days, 3:53
# 11 min
s = ''
if days > 0:
s += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
if len(s) > 0 or hours > 0:
s += '%s:%s' % (str(hours).rjust(2), str(minutes).rjust(2, '0'))
else:
s += '%s min' % (str(minutes))
return s
# vim: set sw=4 et: