如何打印在我的共享文件夹中删除文件的客户端电脑的 IP 或主机名?此代码有效,但它只打印我自己的 IP 和主机名,而不是在我的共享文件夹中删除文件的另一台电脑。我使用Centos 6.3。我使用Samba共享我的文件夹。我使用Python 2.7和PYinotify脚本。
这是我的代码
import pyinotify
wm = pyinotify.WatchManager()
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE
class EventHandler(pyinotify.ProcessEvent):
def process_IN_CREATE(self, event):
print "",now.strftime("%b-%d-%Y @ %I:%M %p")," " ,socket.gethostname()," ","Create "," ",event.name," ",event.path
def process_IN_DELETE(self, event):
print "",now.strftime("%b-%d-%Y @ %I:%M %p")," " ,socket.gethostname()," ","Shift+Del","",event.name," ",event.path
handler = EventHandler()
notifier = pyinotify.Notifier(wm, handler)
wdd = wm.add_watch('/echoshare', mask, rec=True)
auto_add = '/echoshare'
notifier.loop()