mirror of
https://github.com/justinccdev/opensimulator-tools.git
synced 2026-08-14 01:07:50 +00:00
Print out tally of user logins and count and total unique logins by name. Don't currently print each login time.
This commit is contained in:
@@ -15,6 +15,11 @@ diagProcessMemoryRe = re.compile("Process memory.*:")
|
||||
def getFormattedTs(ts):
|
||||
return ts.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
"""
|
||||
See if can match login information to the given line.
|
||||
If so, return the name.
|
||||
If not, return None.
|
||||
"""
|
||||
def matchLogin(logline, ts):
|
||||
match = loginRe.search(logline)
|
||||
|
||||
@@ -22,7 +27,10 @@ def matchLogin(logline, ts):
|
||||
# print "Found match for %s" % (logline)
|
||||
firstName = match.group(1)
|
||||
lastName = match.group(2)
|
||||
print "%s Login request %s %s" % (getFormattedTs(ts), firstName, lastName)
|
||||
#print "%s Login request %s %s" % (getFormattedTs(ts), firstName, lastName)
|
||||
return "%s %s" % (firstName, lastName)
|
||||
else:
|
||||
return None;
|
||||
|
||||
def matchDiag(logline, ts):
|
||||
match = diagProcessMemoryRe.search(logline)
|
||||
@@ -49,6 +57,10 @@ def matchTs(logline):
|
||||
|
||||
return None
|
||||
|
||||
############
|
||||
### MAIN ###
|
||||
############
|
||||
|
||||
# Usage
|
||||
if len(sys.argv) == 1:
|
||||
print "Usage: %s <path>+" % sys.argv[0]
|
||||
@@ -56,6 +68,8 @@ if len(sys.argv) == 1:
|
||||
|
||||
filenames = sys.argv[1:]
|
||||
|
||||
loginsByUser = {}
|
||||
|
||||
for filename in filenames:
|
||||
loglines = file(filename).readlines();
|
||||
|
||||
@@ -73,10 +87,23 @@ for filename in filenames:
|
||||
if ts != None:
|
||||
lastTs = ts
|
||||
|
||||
matchLogin(logline, lastTs)
|
||||
loginName = matchLogin(logline, lastTs)
|
||||
if loginName != None:
|
||||
if loginName in loginsByUser:
|
||||
loginsByUser[loginName] += 1
|
||||
else:
|
||||
loginsByUser[loginName] = 1
|
||||
|
||||
matchDiag(logline, lastTs)
|
||||
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
print "Summary"
|
||||
print "Login information"
|
||||
|
||||
for loginName, count in loginsByUser.iteritems():
|
||||
print "%s: %s" % (loginName, count)
|
||||
|
||||
print "Total unique user logins recorded: %s" % (len(loginsByUser))
|
||||
print "Fin"
|
||||
Reference in New Issue
Block a user