Added number of user for modules in statistics.
This commit is contained in:
parent
65f0ea276e
commit
9cc4d9a9e6
1 changed files with 15 additions and 1 deletions
|
@ -10,6 +10,7 @@ from optparse import OptionParser
|
||||||
|
|
||||||
modules = list()
|
modules = list()
|
||||||
modulestats = dict()
|
modulestats = dict()
|
||||||
|
moduleusers = dict()
|
||||||
|
|
||||||
logdir = '/sw/laki/hlrs/system/modules/logs/'
|
logdir = '/sw/laki/hlrs/system/modules/logs/'
|
||||||
enddate = datetime.date.today()
|
enddate = datetime.date.today()
|
||||||
|
@ -20,6 +21,7 @@ parser = OptionParser(usage="%prog [options] [pattern]")
|
||||||
parser.add_option("--logdir", metavar="DIR", dest="logdir")
|
parser.add_option("--logdir", metavar="DIR", dest="logdir")
|
||||||
parser.add_option("--startdate", metavar="YYYY-MM-DD", dest="startdate")
|
parser.add_option("--startdate", metavar="YYYY-MM-DD", dest="startdate")
|
||||||
parser.add_option("--enddate", metavar="YYYY-MM-DD", dest="enddate")
|
parser.add_option("--enddate", metavar="YYYY-MM-DD", dest="enddate")
|
||||||
|
parser.add_option("--nohpc", action="store_true", default=False, dest="nohpc", help="Exclude hpc* accounts from stats")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
if options.logdir :
|
if options.logdir :
|
||||||
logdir = options.logdir
|
logdir = options.logdir
|
||||||
|
@ -45,11 +47,20 @@ for logfilename in os.listdir(logdir) :
|
||||||
for line in f :
|
for line in f :
|
||||||
if ' load' in line and modulepattern in line :
|
if ' load' in line and modulepattern in line :
|
||||||
module = line.split()[-1]
|
module = line.split()[-1]
|
||||||
|
user = line.split()[-3][5:] # remove user: in front
|
||||||
|
if options.nohpc and 'hpc' in user :
|
||||||
|
continue
|
||||||
if module not in modules:
|
if module not in modules:
|
||||||
modules.append(module)
|
modules.append(module)
|
||||||
modulestats[module] = 1
|
modulestats[module] = 1
|
||||||
|
moduleusers[module] = dict()
|
||||||
|
moduleusers[module][user] = 1
|
||||||
else :
|
else :
|
||||||
modulestats[module] = modulestats[module] + 1
|
modulestats[module] = modulestats[module] + 1
|
||||||
|
if user not in moduleusers[module] :
|
||||||
|
moduleusers[module][user] = 1
|
||||||
|
else :
|
||||||
|
moduleusers[module][user] = moduleusers[module][user] + 1
|
||||||
# if ' swap' in line :
|
# if ' swap' in line :
|
||||||
# print line.split()
|
# print line.split()
|
||||||
|
|
||||||
|
@ -57,6 +68,9 @@ for logfilename in os.listdir(logdir) :
|
||||||
print "-"*78
|
print "-"*78
|
||||||
print "Module statistics for " + startdate.strftime('%Y-%m-%d') + " - " + enddate.strftime('%Y-%m-%d')
|
print "Module statistics for " + startdate.strftime('%Y-%m-%d') + " - " + enddate.strftime('%Y-%m-%d')
|
||||||
print "-"*78
|
print "-"*78
|
||||||
|
print "{0:60s}{1:>8s} {2:>8s}".format('module name', '# uses', '# users')
|
||||||
|
print "-"*78
|
||||||
for (v,m) in sorted( ((v,k) for k,v in modulestats.iteritems()), reverse=True) :
|
for (v,m) in sorted( ((v,k) for k,v in modulestats.iteritems()), reverse=True) :
|
||||||
print "{0:70s}{1:>8d}".format(m, v)
|
print "{0:60s}{1:>8d} {2:>8d}".format(m, v, len(moduleusers[m].keys()))
|
||||||
|
#print moduleusers[m]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue