Added option --list-unused listing all unused modules for given pattern.
This commit is contained in:
parent
a02204d66d
commit
2759e769be
1 changed files with 23 additions and 10 deletions
|
@ -6,6 +6,7 @@
|
|||
import os
|
||||
import datetime
|
||||
from optparse import OptionParser
|
||||
import subprocess
|
||||
|
||||
|
||||
modules = list()
|
||||
|
@ -25,6 +26,7 @@ parser.add_option("--startdate", metavar="YYYY-MM-DD", dest="startdate")
|
|||
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")
|
||||
parser.add_option("--printusers", action="store_true", default=False, dest="printusers", help="Print detailed user lists for module usage.")
|
||||
parser.add_option("--list-unused", action="store_true", default=False, dest="list_unused", help="List only unused modules.")
|
||||
(options, args) = parser.parse_args()
|
||||
if options.logdir :
|
||||
logdir = options.logdir
|
||||
|
@ -69,10 +71,21 @@ for logfilename in os.listdir(logdir) :
|
|||
# if ' swap' in line :
|
||||
# print line.split()
|
||||
|
||||
|
||||
print "-"*78
|
||||
print "Module statistics for " + startdate.strftime('%Y-%m-%d') + " - " + enddate.strftime('%Y-%m-%d')
|
||||
print "-"*78
|
||||
if options.list_unused :
|
||||
print "Unused modules:"
|
||||
print "-"*78
|
||||
avail_modules = []
|
||||
p = subprocess.Popen("module -l av " + modulepattern, shell=True, stderr=subprocess.PIPE).stderr
|
||||
for line in p :
|
||||
if modulepattern in line :
|
||||
avail_modules.append(line.split()[0])
|
||||
for module in avail_modules :
|
||||
if not module in modulestats :
|
||||
print module
|
||||
else :
|
||||
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) :
|
||||
|
|
Loading…
Reference in a new issue