-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (26 loc) · 879 Bytes
/
main.py
File metadata and controls
37 lines (26 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import time
from watchdog.observers import Observer
from collector import MonitorHandler, get_buffer
from analyzer import analyze
from scorer import calculate_risk
from exporter import export_json
MONITOR_PATH = "/home/mohit/TestingDirectory"
def main():
observer = Observer()
observer.schedule(MonitorHandler(), MONITOR_PATH, recursive=True)
observer.start()
print("Monitoring started...")
try:
while True:
time.sleep(1)
buffer = list(get_buffer()) # snapshot copy
features = analyze(buffer)
risk, suspicious = calculate_risk(features)
print(features)
print(f"Risk: {risk}, Suspicious: {suspicious}")
export_json(features, risk, suspicious)
except KeyboardInterrupt:
observer.stop()
observer.join()
if __name__ == "__main__":
main()