Created
June 12, 2014 21:32
-
-
Save mortn/91a6a94913ba433c478f to your computer and use it in GitHub Desktop.
pyinotify example for watching DHCP leases file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyinotify,subprocess | |
def onChange(ev): | |
cmd = ['/bin/echo', 'File', ev.pathname, 'changed'] | |
subprocess.Popen(cmd).communicate() | |
wm = pyinotify.WatchManager() | |
wm.add_watch('/var/lib/dhcp/dhcpd.leases', pyinotify.IN_MODIFY, onChange) | |
notifier = pyinotify.Notifier(wm) | |
notifier.loop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment