-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_opensyslog.py
29 lines (23 loc) · 995 Bytes
/
main_opensyslog.py
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
import sys
from opensyslog_helper import OpensyslogHelper
from opensyslog_syslog import OpensyslogSyslog
class OpensyslogMonitor:
def __init__(self, config_folder):
self.helper = OpensyslogHelper(config_folder)
self.helper.print(self.helper.log_level_info, "OpensyslogMonitor: Starting Monitor")
self.syslog = OpensyslogSyslog(self.helper)
while True:
try:
self.helper.print(self.helper.log_level_debug, "OpensyslogMonitor: Start syslog monitor loop")
self.syslog.monitor()
except Exception as e:
self.helper.print(self.helper.log_level_error, "OpensyslogMonitor: Exception: " + str(e))
if __name__ == '__main__':
if len(sys.argv) > 1:
root_path = sys.argv[1]
if not root_path.endswith("/"):
root_path = root_path + "/"
else:
root_path = "/config/"
print("Config folder: " + root_path)
main_object = OpensyslogMonitor(root_path)