mirror of
https://github.com/aljazceru/cowrie.git
synced 2025-12-17 14:04:28 +01:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user