diff --git a/Other/auto-acknowledge-apt.sh b/Other/auto-acknowledge-apt.sh index a389dba..e68e3c4 100755 --- a/Other/auto-acknowledge-apt.sh +++ b/Other/auto-acknowledge-apt.sh @@ -38,7 +38,8 @@ payload='{ while true; do response=$(curl -s -o /dev/null -w "%{http_code}" -X POST -H "Accept: application/json" -u "$user:$password" -d "$payload" -k "$api/v1/actions/acknowledge-problem") - if [ "$response" == "200" ]; then + if [ "$response" == "200" ] || [ "$response" == "409" ]; then + # 409 is okay because that means it's already been acknowledged. echo "All pending alerts have been acknowledged." else echo "Failed to acknowledge the alerts. Status code: $response" diff --git a/Other/icinga2kuma.py b/Other/icinga2kuma.py index 2a6945e..16caf31 100755 --- a/Other/icinga2kuma.py +++ b/Other/icinga2kuma.py @@ -7,6 +7,8 @@ import urllib3 from flask import Flask, Response, request from icinga2api.client import Client +script_dir = os.path.dirname(os.path.realpath(__file__)) +sys.path.insert(0, str(Path(script_dir).parent)) from checker import nagios # TODO: add query arg to not return an error when the host check is down diff --git a/services/auto-acknowledge-apt.service b/services/auto-acknowledge-apt.service index 5ddb1a1..4ba2a2d 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 queeyahnahz3Zie1 +ExecStart=/opt/icinga2-checks/Other/auto-acknowledge-apt.sh --api https://localhost:5665 --user icingaweb2 --password XXXXX SyslogIdentifier=auto-acknowledge-apt Restart=always