IGNORE_PATHS = set((
'/dev/zero',
'/etc/ld.so.cache',
+ '/usr/share/icons/Adwaita/icon-theme.cache',
+ '/usr/share/icons/gnome/icon-theme.cache',
+ '/usr/share/icons/hicolor/icon-theme.cache',
+ '/usr/share/mime/mime.cache',
))
# 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('/memfd:') or
path.startswith('/SYSV') or
- path.startswith('/dev/shm/')):
+ path.startswith('/dev/shm/') or
+ path.startswith('/tmp/')):
continue
old_paths.add(path)
'/usr/sbin/bacula-fd': 'bacula-fd',
'/usr/sbin/cron': 'vixie-cron',
'/usr/sbin/crond': 'dcron',
+ '/usr/sbin/ntpd': 'ntpd',
'/usr/sbin/snmpd': 'snmpd',
'/usr/sbin/sshd': 'sshd',
'/usr/sbin/syslog-ng': 'syslog-ng',
'/usr/bin/daisydog': 'daisydog',
'/usr/bin/distccd': 'distccd',
'/usr/bin/monit': 'monit',
+ '/usr/bin/rsync': 'rsyncd',
'/usr/bin/stunnel': 'stunnel',
'/usr/bin/tor': 'tor',
'/usr/bin/transmission-daemon': 'transmission-daemon',
'/usr/bin/mediatomb': 'mediatomb',
'/lib/systemd/systemd-udevd': 'udev',
'/usr/libexec/nrpe': 'nrpe',
- '/usr/libexec/postfix/master': 'postfix',
+ '//usr/libexec/postfix/master': 'postfix',
'denyhosts.py': 'denyhosts',
'dropbear': 'dropbear',
'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)