fix: make async icinga curl optiona

This commit is contained in:
2024-12-29 15:31:13 +00:00
parent 581e741470
commit f7e4d95ef9
2 changed files with 7 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ import json
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates")) environment = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="./templates"))
def createBackupScriptStructure(backupList, baseDomain="", icingaOnly=False): def createBackupScriptStructure(backupList, baseDomain="", icingaOnly=False, backup_no_async_icinga=True):
backupPath = "./build/backup/" backupPath = "./build/backup/"
@@ -107,7 +107,8 @@ def createBackupScriptStructure(backupList, baseDomain="", icingaOnly=False):
rsyncScript = rsyncScriptTemplate.render(hostname=hostname, token=icingaToken, rsyncScript = rsyncScriptTemplate.render(hostname=hostname, token=icingaToken,
hostname_base=hostnameBase, hostname_base=hostnameBase,
size_change_commands=sizeChangeNotifyCommands) size_change_commands=sizeChangeNotifyCommands,
backup_no_async_icinga=backup_no_async_icinga)
# build all filter # # build all filter #
rsyncFilterAll = rsyncFilterTemplate.render(paths=pathsAll) rsyncFilterAll = rsyncFilterTemplate.render(paths=pathsAll)

View File

@@ -45,8 +45,10 @@ SERVICE="backup_{{ hostname_base }}"
TOKEN="{{ token }}" TOKEN="{{ token }}"
if [ $RSYNC_SUCCESS -eq 0 ]; then if [ $RSYNC_SUCCESS -eq 0 ]; then
{% if not backup_no_async_icinga %}
curl -H "${CONTENT_TYPE}" -X POST "${ASYNC_ICINGA_ADDRESS}" -d \ curl -H "${CONTENT_TYPE}" -X POST "${ASYNC_ICINGA_ADDRESS}" -d \
"{\"service\": \"${SERVICE}\", \"token\": \"${TOKEN}\", \"status\": \"OK\", \"info\": \"\"}" "{\"service\": \"${SERVICE}\", \"token\": \"${TOKEN}\", \"status\": \"OK\", \"info\": \"\"}"
{% endif %}
# if size changed was copied save new size # # if size changed was copied save new size #
{% if not size_change_commands %} {% if not size_change_commands %}
@@ -56,8 +58,10 @@ if [ $RSYNC_SUCCESS -eq 0 ]; then
{{ cmd }} {{ cmd }}
{% endfor %} {% endfor %}
else else
{% if not backup_no_async_icinga %}
curl -H "${CONTENT_TYPE}" -X POST "${ASYNC_ICINGA_ADDRESS}" -d \ curl -H "${CONTENT_TYPE}" -X POST "${ASYNC_ICINGA_ADDRESS}" -d \
"{\"service\": \"${SERVICE}\", \"token\": \"${TOKEN}\", \"status\": \"CRITICAL\", \"info\": \"\"}" "{\"service\": \"${SERVICE}\", \"token\": \"${TOKEN}\", \"status\": \"CRITICAL\", \"info\": \"\"}"
{% endif %}
fi fi
cd .. cd ..