Update signl4.py

pull/1374/head
Ron 2025-07-29 15:15:08 +02:00
parent a07a382480
commit 71650b141e
1 changed files with 26 additions and 19 deletions

View File

@ -32,7 +32,6 @@
import requests import requests
from json import dumps from json import dumps
from .base import NotifyBase from .base import NotifyBase
from ..url import PrivacyMode from ..url import PrivacyMode
from ..common import NotifyType from ..common import NotifyType
@ -103,8 +102,9 @@ class NotifySIGNL4(NotifyBase):
}, },
}) })
def __init__(self, secret, service=None, location=None, alerting_scenario=None, def __init__(self, secret, service=None, location=None,
filtering=None, external_id=None, status=None, **kwargs): alerting_scenario=None, filtering=None,
external_id=None, status=None, **kwargs):
""" """
Initialize SIGNL4 Object Initialize SIGNL4 Object
""" """
@ -176,10 +176,9 @@ class NotifySIGNL4(NotifyBase):
# Prepare our URL # Prepare our URL
notify_url = self.service_url + self.secret notify_url = self.service_url + self.secret
self.logger.debug("SIGNL4 POST URL: %s (cert_verify=%r)" % ( self.logger.debug("SIGNL4 POST URL: {notify_url} \
notify_url, self.verify_certificate, (cert_verify={self.verify_certificate}")
)) self.logger.debug("SIGNL4 Payload: {payload}")
self.logger.debug("SIGNL4 Payload: %s" % str(payload))
# Always call throttle before any remote server i/o is made # Always call throttle before any remote server i/o is made
self.throttle() self.throttle()
@ -218,8 +217,8 @@ class NotifySIGNL4(NotifyBase):
except requests.RequestException as e: except requests.RequestException as e:
self.logger.warning( self.logger.warning(
"A Connection error occurred sending SIGNL4 " "A Connection error occurred sending SIGNL4 "
"notification to %s." % self.host) "notification to {self.host}.")
self.logger.debug("Socket Exception: %s" % str(e)) self.logger.debug("Socket Exception: " + str(e))
# Return; we're done # Return; we're done
return False return False
@ -300,21 +299,29 @@ class NotifySIGNL4(NotifyBase):
NotifySIGNL4.unquote(results["host"]) NotifySIGNL4.unquote(results["host"])
if "service" in results["qsd"] and len(results["qsd"]["service"]): if "service" in results["qsd"] and len(results["qsd"]["service"]):
results["service"] = NotifySIGNL4.unquote(results["qsd"]["service"]) results["service"] = \
NotifySIGNL4.unquote(results["qsd"]["service"])
if "location" in results["qsd"] and len(results["qsd"]["location"]):
results["location"] = NotifySIGNL4.unquote(results["qsd"]["location"])
if "alerting_scenario" in results["qsd"] and len(results["qsd"]["alerting_scenario"]): if "location" in results["qsd"] and len(results["qsd"]["location"]):
results["alerting_scenario"] = NotifySIGNL4.unquote(results["qsd"]["alerting_scenario"]) results["location"] = \
NotifySIGNL4.unquote(results["qsd"]["location"])
if "alerting_scenario" in results["qsd"] and \
len(results["qsd"]["alerting_scenario"]):
results["alerting_scenario"] = \
NotifySIGNL4.unquote(results["qsd"]["alerting_scenario"])
if "filtering" in results["qsd"] and len(results["qsd"]["filtering"]): if "filtering" in results["qsd"] and len(results["qsd"]["filtering"]):
results["filtering"] = NotifySIGNL4.unquote(results["qsd"]["filtering"]) results["filtering"] = \
NotifySIGNL4.unquote(results["qsd"]["filtering"])
if "external_id" in results["qsd"] and len(results["qsd"]["external_id"]): if "external_id" in results["qsd"] and \
results["external_id"] = NotifySIGNL4.unquote(results["qsd"]["external_id"]) len(results["qsd"]["external_id"]):
results["external_id"] = \
NotifySIGNL4.unquote(results["qsd"]["external_id"])
if "status" in results["qsd"] and len(results["qsd"]["status"]): if "status" in results["qsd"] and len(results["qsd"]["status"]):
results["status"] = NotifySIGNL4.unquote(results["qsd"]["status"]) results["status"] = \
NotifySIGNL4.unquote(results["qsd"]["status"])
return results return results