import argparse import json import time import requests from urllib3.exceptions import InsecureRequestWarning parser = argparse.ArgumentParser(description='Check OPNsense network traffic for a host.') parser.add_argument('--api', required=True, help='Full URL to your Icinga2 API.') parser.add_argument('--user', required=True, help='API username.') parser.add_argument('--password', required=True, help='API password.') args = parser.parse_args() # Acknowledge all services that meet this filter. requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning) payload = { "type": "Service", "filter": "service.name == \"apt\" && service.acknowledgement == 0", "author": "Auto-Acknowledgement Script", "comment": "This alert has been automatically acknowledged.", "notify": True, "pretty": True } while True: response = requests.post(f'{args.api}/v1/actions/acknowledge-problem', headers={"Accept": "application/json"}, auth=(args.user, args.password), data=json.dumps(payload), verify=False) if response.status_code == 200: print("All pending alerts have been acknowledged.") else: print("Failed to acknowledge the alerts. Status code:", response.status_code) print(response.text) time.sleep(60)