diff --git a/PROGRESS.md b/PROGRESS.md index 8723ea4..b60c6d2 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -71,7 +71,8 @@ - [x] Change baseline calculations to only use integers instead of floats. - [x] Add a log file that only keeps records for the past 24 hours. - [x] Log all LLM responses to the console. -- [ ] Reduce alerts to only happen between 9am and 12am. +- [x] Reduce alerts to only happen between 9am and 12am. - [ ] Get hostnames of devices in Nmap scan. - [ ] Filter out RTT fluctuations below 10 seconds. -- [ ] Filter out temperature fluctuations with differences less than 5 degrees. \ No newline at end of file +- [ ] Filter out temperature fluctuations with differences less than 5 degrees. +- [ ] Create a list of known port numbers and their applications for the LLM to check against to see if an open port is a threat \ No newline at end of file diff --git a/monitor_agent.py b/monitor_agent.py index 77670d4..27d9db0 100644 --- a/monitor_agent.py +++ b/monitor_agent.py @@ -301,7 +301,7 @@ def send_google_home_alert(message): simplified_message = response['response'].strip() except Exception as e: logger.error(f"Error summarizing message: {e}") - simplified_message = message.split('.')[0] # Take the first sentence as a fallback + simplified_.message = message.split('.')[0] # Take the first sentence as a fallback url = f"{config.HOME_ASSISTANT_URL}/api/services/tts/speak" headers = { @@ -324,6 +324,11 @@ def send_google_home_alert(message): # --- Main Script Logic --- +def is_alerting_time(): + """Checks if the current time is within the alerting window (9am - 12am).""" + current_hour = datetime.now().hour + return 9 <= current_hour < 24 + daily_events = [] def run_monitoring_cycle(nmap_scan_counter): @@ -361,7 +366,7 @@ def run_monitoring_cycle(nmap_scan_counter): if llm_response and llm_response.get('severity') != "none": daily_events.append(llm_response.get('reason')) - if llm_response.get('severity') == "high": + if llm_response.get('severity') == "high" and is_alerting_time(): send_discord_alert(llm_response.get('reason')) send_google_home_alert(llm_response.get('reason')) return nmap_scan_counter @@ -386,4 +391,4 @@ def main(): time.sleep(300) # Run every 5 minutes if __name__ == "__main__": - main() + main() \ No newline at end of file