feat: Add env variable for monitor interval
All checks were successful
Lint & Compile Check / check (push) Successful in 5s

This commit is contained in:
2026-03-12 21:43:32 +01:00
parent 8df1ada71f
commit 04db9a93b6

View File

@@ -229,6 +229,9 @@ if __name__ == "__main__":
parser.add_argument("--test", action="store_true", help="Send a fake test notification and exit") parser.add_argument("--test", action="store_true", help="Send a fake test notification and exit")
args = parser.parse_args() args = parser.parse_args()
# Update interval from environment if provided as override
interval = int(os.getenv("MONITOR_INTERVAL", args.interval))
if args.test: if args.test:
import random import random
test_ip, test_name = random.choice(list(CLIENTS.items())) test_ip, test_name = random.choice(list(CLIENTS.items()))
@@ -239,10 +242,10 @@ if __name__ == "__main__":
logger.info("Test notification sent. Exiting.") logger.info("Test notification sent. Exiting.")
exit(0) exit(0)
logger.info(f"AdGuard Monitor Service Started. Interval: {args.interval}s") logger.info(f"AdGuard Monitor Service Started. Interval: {interval}s")
logger.info(f"Monitoring {len(CLIENTS)} clients: {', '.join([f'{name} ({ip})' for ip, name in CLIENTS.items()])}") logger.info(f"Monitoring {len(CLIENTS)} clients: {', '.join([f'{name} ({ip})' for ip, name in CLIENTS.items()])}")
session = get_auth_session() session = get_auth_session()
while True: while True:
fetch_and_analyze(session, verbose=args.verbose) fetch_and_analyze(session, verbose=args.verbose)
time.sleep(args.interval) time.sleep(interval)