diff --git a/Other/auto-acknowledge-apt.sh b/Other/auto-acknowledge-apt.sh index e68e3c4..4f94f1f 100755 --- a/Other/auto-acknowledge-apt.sh +++ b/Other/auto-acknowledge-apt.sh @@ -2,10 +2,12 @@ # Check OPNsense network traffic for a host. usage() { - echo "Usage: $0 --api --user --password " + echo "Usage: $0 --api --user --password [--fail]" exit 1 } +EXIT_ON_FAILURE=false + while [ "$1" != "" ]; do case $1 in --api ) shift @@ -17,6 +19,9 @@ while [ "$1" != "" ]; do --password ) shift password=$1 ;; + --fail ) shift + EXIT_ON_FAILURE=true + ;; * ) usage esac shift @@ -43,6 +48,9 @@ while true; do echo "All pending alerts have been acknowledged." else echo "Failed to acknowledge the alerts. Status code: $response" + if $EXIT_ON_FAILURE; then + exit 1 + fi fi sleep 60 done diff --git a/Other/fail-overdue.py b/Other/fail-overdue.py index 07aea9c..ba4c8e7 100755 --- a/Other/fail-overdue.py +++ b/Other/fail-overdue.py @@ -75,7 +75,7 @@ def main(args): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument('--api', default='http://localhost:5665', help='Base Icinga2 API.') + parser.add_argument('--api', default='https://localhost:5665', help='Base Icinga2 API.') parser.add_argument('--insecure', action='store_true', help='Disable SSL verification.') parser.add_argument('--username', default='icingaweb2', help='API username.') parser.add_argument('--password', required=True, help='API password.') diff --git a/services/auto-acknowledge-apt.service b/services/auto-acknowledge-apt.service index 4ba2a2d..4c438c5 100644 --- a/services/auto-acknowledge-apt.service +++ b/services/auto-acknowledge-apt.service @@ -3,7 +3,7 @@ Description=Auto Acknowledge all Icinga2 apt alerts [Service] User=flask -ExecStart=/opt/icinga2-checks/Other/auto-acknowledge-apt.sh --api https://localhost:5665 --user icingaweb2 --password XXXXX +ExecStart=/opt/icinga2-checks/Other/auto-acknowledge-apt.sh --api https://localhost:5665 --fail --user icingaweb2 --password XXXXX SyslogIdentifier=auto-acknowledge-apt Restart=always