#!/usr/bin/python import sys sys.path.append("/usr/share/rhn/up2date_client") sys.path.append("/usr/share/rhn/rhn_applet") import os import re import string import rhn_utils import rhn_applet_rpm rpm = rhn_applet_rpm.rhnAppletRPM() seen_cache = {} for dir in os.listdir("/proc"): try: pid = int(dir) except ValueError: continue # have to wrap in a try because, alas, processes die try: mapfile = open("/proc/%s/maps" % dir) except IOError: continue for line in map(lambda s: string.strip(s), mapfile): fields = string.split(line, " ") if fields[-1] != "(deleted)": continue if seen_cache.has_key(fields[-2]): continue seen_cache[fields[-2]] = 1 # walk the filename backwards with dots. the exact # filename, libfoo.so.2.12 was probably removed and not # changed in place, but the libfoo.so.2 may not have been. # or, libfoo.so may not have been. walk backwards. components = string.split(fields[-2], ".") # start with -1 since the file is gone... and because of a # kernel bug that misprints the last component i = len(components) - 1 while i > 0: filename = string.join(components[0:i], ".") packagename = rpm.find_provides_by_file(filename) if packagename: print "Stale library by pid %s: %s (%s)" % (dir, filename, packagename) break i = i - 1