def is_valid_glocktop_file(path_to_filename): try: fin = open(path_to_filename) for line in fin.readlines()[0:10]: if (line.startswith("@")): if (not parse_snapshot(line) == None): return True except (UnicodeEncodeError, IOError): return False return False
def __analyze_file(path_to_output_file, gfs2_filesystem_names, show_ended_process_and_tlocks): #All the snapshots for all the filesystems. snapshots_by_filesystem = {} # The glock that will have a container for all the lines associated with # the glock. gfs2_snapshot = None # The lines that are related to this snapshot of the # filesystem. Including glocks, waiters, etc. snapshot_lines = [] lines = get_data_from_file(path_to_filename) for line in lines: # @, G, H, I, R, B, U, C, S if ((line.startswith("@")) or (not len(line) > 0)): if (not gfs2_snapshot == None): # Process any previous snapshot lines before starting a # new one. All the glocks, holder/waiters, etc. if ((not gfs2_filesystem_names) or (gfs2_snapshot.get_filesystem_name().strip() in gfs2_filesystem_names)): process_snapshot(gfs2_snapshot, snapshot_lines) if (not snapshots_by_filesystem.has_key(gfs2_snapshot.get_filesystem_name())): snapshots_by_filesystem[gfs2_snapshot.get_filesystem_name()] = [] snapshots_by_filesystem[gfs2_snapshot.get_filesystem_name()].append(gfs2_snapshot) # Process the new snapshot gfs2_snapshot = parse_snapshot(line, show_ended_process_and_tlocks) snapshot_lines = [] else: snapshot_lines.append(line) # Process any remaining items if (not gfs2_snapshot == None): if ((not gfs2_filesystem_names) or (gfs2_snapshot.get_filesystem_name().strip() in gfs2_filesystem_names)): process_snapshot(gfs2_snapshot, snapshot_lines) if (not snapshots_by_filesystem.has_key(gfs2_snapshot.get_filesystem_name())): snapshots_by_filesystem[gfs2_snapshot.get_filesystem_name()] = [] snapshots_by_filesystem[gfs2_snapshot.get_filesystem_name()].append(gfs2_snapshot) return snapshots_by_filesystem