improve icinga2kuma

This commit is contained in:
Cyberes 2024-09-08 13:45:31 -06:00
parent 2bc293dc57
commit b8849d200f
1 changed files with 11 additions and 3 deletions

View File

@ -36,9 +36,9 @@ app = Flask(__name__)
@app.route("/host/<hostid>")
def get_host_state(hostid=None):
path = Path(request.base_url)
args_service = request.args.getlist('service')
args_exclude_service = request.args.getlist('exclude') # do not list these services
args_ignore_service = request.args.getlist('ignore') # do not trigger a fail if these services fail
args_service = request.args.get('service', '').split(',')
args_exclude_service = request.args.get('exclude', '').split(',') # do not list these services
args_ignore_service = request.args.get('ignore', '').split(',') # do not trigger a fail if these services fail
kuma_mode = True if request.args.get('kuma') == 'true' else False
if not hostid:
@ -81,6 +81,10 @@ def get_host_state(hostid=None):
}
}
for i in range(len(args_service)):
if '+' in args_service[i]:
args_service[i].replace('+', ' ')
if len(args_service):
services = {}
for service in args_service:
@ -101,3 +105,7 @@ def get_host_state(hostid=None):
return Response(json.dumps(result), status=410, mimetype='application/json')
else:
return result
if __name__ == '__main__':
app.run()