Skip to content

Commit

Permalink
Add global timeout #30. Thanks @Gill-Bates
Browse files Browse the repository at this point in the history
  • Loading branch information
ddbnl committed Jun 14, 2022
1 parent c5844e3 commit 2df5950
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ConfigExamples/fullConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ collect: # Settings determining which audit logs to collect and how to do it
Audit.Exchange: True
Audit.SharePoint: True
DLP.All: True
rustEngine: True # Use False to revert to the old Python engine. If running from python instead of executable, make sure to install the python wheel in the RustEngineWheels folder
rustEngine: True # Use False to revert to the old Python engine. If running from python instead of executable, make sure to install the Rust enginej python wheel in the RustEngineWheels folder
# schedule: 0 1 0 # How often to run in days/hours/minutes. Program will never exit and run on the schedule. Uncomment to use.
maxThreads: 50 # Maximum number of simultaneous threads retrieving logs
globalTimeout: 0 # Number of minutes before the process is forced to exit if still running (0 = no timeout). If you run e.g. every hour you could set this to 59, ensuring there will only be 1 active process.
retries: 3 # Times to retry retrieving a content blob if it fails
retryCooldown: 3 # Seconds to wait before retrying retrieving a content blob
autoSubscribe: True # Automatically subscribe to collected content types. Never unsubscribes from anything.
Expand Down
Binary file not shown.
9 changes: 9 additions & 0 deletions Source/AuditLogCollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def run_once(self):
self.receive_results_from_rust_engine()
self._stop_interfaces(force=False)
else:
logging.warning(
"WARNING: The Python engine is deprecated; it will be removed in a future version as it has been "
"replaced by the Rust engine. Consider removing the 'rustEngine: False' line in your config. If you "
"are experiencing issues with the Rust engine, please consider creating an issue on the GitHub repo so "
"it can be fixed (https://github.com/ddbnl/office365-audit-log-collector/issues)")
self._start_monitoring()
self._get_all_available_content()
while self.monitor_thread.is_alive():
Expand All @@ -95,8 +100,12 @@ def receive_results_from_rust_engine(self):
self.config['collect', 'retries'] or 3)
engine.run_once()
last_received = datetime.datetime.now()
timeout = self.config['collect', 'globalTimeout']
while True:
try:
if timeout and datetime.datetime.now() - self.run_started >= datetime.timedelta(minutes=timeout):
logging.error("Global timeout reached, killing process.")
sys.exit(-1)
result = engine.get_result()
except ValueError: # RustEngine throws this error when no logs are in the results recv queue
now = datetime.datetime.now()
Expand Down
Binary file not shown.

0 comments on commit 2df5950

Please sign in to comment.