diff --git a/gpfs-scan-files.py b/gpfs-scan-files.py index cea3ac3..0300b88 100755 --- a/gpfs-scan-files.py +++ b/gpfs-scan-files.py @@ -69,7 +69,7 @@ def _ncheck_output(cmds): def get_hostname(): return os.uname()[1] -def run_mmapplypolicy(exefile, target_dir, policy_file, temp_dir, out_dir): +def run_mmapplypolicy(exefile, target_dir, policy_file, temp_dir, out_dir, include_dir_file): # Ensure we are runnning mmapplypolicy on the correct host hostname = get_hostname() if not hostname in MMAPPLY_HOSTS: @@ -91,7 +91,19 @@ def run_mmapplypolicy(exefile, target_dir, policy_file, temp_dir, out_dir): # Inode_number, gen_number, snapshot_id, access_time, kb_allocated, file_size, "--", filename # The first three and last two columns are always present, the other columns are determined # from the SHOW policy command - cmd = "%(exefile)s %(target_dir)s -s %(temp_dir)s -I defer -P %(policy_file)s -f %(out_dir)s" % locals() + # MMAPPLYPOLICY OPTIONS + # -s Location of temporary directories used by mmapplypolicy. Must be on same device as that scanned. + # -I 'defer'. Always used when doing a list. Just one of those things ... + # -P Location of policy file + # -f Location of output files + # -i File list list of directories to include. Must exclude .snapshot from this list. We also + # exclude /gpfs/scratchfs/BROKEN, which contains borked tmp/ and tmp_ard/ - these are broken + # and cause mmapplypolicy to hang indefinitely. + # -a4 Number of threads to use. Default is 2. + if include_dir_file==None: + cmd = "%(exefile)s %(target_dir)s -s %(temp_dir)s -I defer -P %(policy_file)s -f %(out_dir)s -a4" % locals() + else: + cmd = "%(exefile)s %(target_dir)s -s %(temp_dir)s -I defer -P %(policy_file)s -f %(out_dir)s -i %(include_dir_file)s -a4" % locals() p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) out,err = p.communicate() with open(out_dir + "/mm.out", "w") as fout: print(out,file=fout) @@ -247,7 +259,7 @@ def add_date(datetime, days): # Read arguments from command line def parse_args(args): try: - opts,args = getopt.getopt(sys.argv[1:],'s:p:D:C:H:hId:o:') + opts,args = getopt.getopt(sys.argv[1:],'s:p:D:C:H:hId:o:i:') except getopt.GetoptError as e: Usage(" ERROR: " + str(e)) opts = dict(opts) @@ -327,11 +339,12 @@ def main(): # Scan directories with mmapplypolicy, and write to list.all-files in out_dir if '-s' in opts: - out_dir = opts['-o'] if '-o' in opts else tempfile.mkdtemp(DEF_OUTDIR) - temp_dir = out_dir + "/tmp" - policy_file = out_dir + "/policy_file" - target_dir = opts['-s'] - rc = run_mmapplypolicy(MMAPPLYPOLICY,target_dir,policy_file,temp_dir,out_dir) + out_dir = opts['-o'] if '-o' in opts else tempfile.mkdtemp(DEF_OUTDIR) + temp_dir = out_dir + "/tmp" + policy_file = out_dir + "/policy_file" + target_dir = opts['-s'] + include_dir_file = opts['-i'] if '-i' in opts else None + rc = run_mmapplypolicy(MMAPPLYPOLICY,target_dir,policy_file,temp_dir,out_dir, include_dir_file) #rc = run_test(temp_dir,out_dir) if rc>0: print_warn(" mmapplypolicy return code is (%d)" % rc)