# b71c7000-b7307000 rw-s 00000000 00:04 17024337 /dev/zero (deleted)
addr, perm, offset, dev, inode, path = line.split(' ', 5)
# Handle paths with spaces.
- path = path.rsplit(' ', 2)[0]
+ path = path.lstrip().rsplit(' ', 2)[0]
if (path == '/[aio]' or
path.startswith('/SYSV') or
- path.startswith('/dev/shm/')):
+ path.startswith('/dev/shm/') or
+ path.startswith('/tmp/')):
continue
old_paths.add(path)
'galileo': 'galileo',
'tlsdated': 'tlsdated',
}
-def auto_restart(svcs):
+def auto_restart(opts, svcs):
kill = set()
restart = set()
for pid, svc in svcs.items():
if kill or restart:
for pid in kill:
print('killing %s (%s)' % (pid, svcs[pid]['cmdline'][0]))
- os.kill(pid, signal.SIGTERM)
+ if not opts.dryrun:
+ os.kill(pid, signal.SIGTERM)
for init in restart:
print('restarting %s' % init)
- os.system('/etc/init.d/%s -q restart' % init)
+ if not opts.dryrun:
+ os.system('/etc/init.d/%s -q restart' % init)
- time.sleep(1)
- svcs = find_svcs()
+ if not opts.dryrun:
+ time.sleep(1)
+ svcs = find_svcs()
return svcs
def get_parser():
parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('-n', '--dry-run', dest='dryrun', action='store_true',
+ help='Show what would be restarted (and why)')
return parser
opts = parser.parse_args(argv)
svcs = find_svcs()
- svcs = auto_restart(svcs)
+ svcs = auto_restart(opts, svcs)
summarize(svcs)