# !/usr/bin/env python # -*-coding:utf-8 -*- """ # File : run.py.py # Time :2024/6/30 上午 12:23 # Modify :sityliu # Author :蓝陌 # version :python 3.8 # Description:服务器登录检测,当检测到登录行为时自动发送钉钉消息 """ import os from src.message_sed import MessageSedes sed = MessageSedes() def monitoring_login_behavior(): login_num = 0 while True: if login_num == 0: print('开始监控登录行为......') os.popen('inotifywait -e modify /var/log/wtmp > /dev/null').readlines() sed.run() login_num += 1 os.popen('inotifywait -e modify /var/log/wtmp > /dev/null').readlines() login_num = 0 if __name__ == '__main__': # sed.run() monitoring_login_behavior()