From 79184e8345be807c602d5eaf83ab1ba8f6c4c729 Mon Sep 17 00:00:00 2001 From: Ron <43244104+rons4@users.noreply.github.com> Date: Wed, 22 May 2024 17:16:35 +0200 Subject: [PATCH] SIGNL4 Alert Transport (#16037) * SIGNL4 Alert Transport SIGNL4 alert transport added. * Update Transports.md * Update Signl4.php --- LibreNMS/Alert/Transport/Signl4.php | 78 +++++++++++++++++++++++++++++ doc/Alerting/Transports.md | 16 ++++++ 2 files changed, 94 insertions(+) create mode 100644 LibreNMS/Alert/Transport/Signl4.php diff --git a/LibreNMS/Alert/Transport/Signl4.php b/LibreNMS/Alert/Transport/Signl4.php new file mode 100644 index 0000000000..92b048bab2 --- /dev/null +++ b/LibreNMS/Alert/Transport/Signl4.php @@ -0,0 +1,78 @@ +. */ + +/** + * API Transport + * + * @author SIGNL4 + * @copyright 2024 SIGNL4 + * @license GPL + */ + +namespace LibreNMS\Alert\Transport; + +use LibreNMS\Alert\Transport; +use LibreNMS\Enum\AlertState; +use LibreNMS\Exceptions\AlertTransportDeliveryException; +use LibreNMS\Util\Http; + +class Signl4 extends Transport +{ + protected string $name = 'SIGNL4'; + + public function deliverAlert(array $alert_data): bool + { + $url = $this->config['signl4-url']; + + $alert_status = match ($alert_data['state']) { + AlertState::RECOVERED => 'resolved', + AlertState::ACKNOWLEDGED => 'acknowledged', + default => 'new' + }; + + $s4_data = [ + 'X-S4-ExternalID' => (string) $alert_data['alert_id'], + 'X-S4-Status' => $alert_status, + 'Body' => $alert_data['alert_notes'], + ]; + + $data = array_merge($s4_data, $alert_data); + + $res = Http::client()->post($url, $data); + + if ($res->successful()) { + return true; + } + + throw new AlertTransportDeliveryException($alert_data, $res->status(), $res->body(), '', $alert_data); + } + + public static function configTemplate(): array + { + return [ + 'config' => [ + [ + 'title' => 'Webhook URL', + 'name' => 'signl4-url', + 'descr' => 'SIGNL4 webhook URL including team or integration secret.', + 'type' => 'text', + ], + ], + 'validation' => [ + 'signl4-url' => 'required|url', + ], + ]; + } +} diff --git a/doc/Alerting/Transports.md b/doc/Alerting/Transports.md index db56badb1f..df56adbd0f 100644 --- a/doc/Alerting/Transports.md +++ b/doc/Alerting/Transports.md @@ -764,6 +764,22 @@ Sensu to LibreNMS alerts, they'll be lost on the next event (silences will work) | Check Prefix | lnms | | Source Key | hostname | +## SIGNL4 + +SIGNL4 offers critical alerting, incident response and service dispatching for operating critical infrastructure. It alerts you persistently via app push, SMS text, voice calls, and email including tracking, escalation, on-call duty scheduling and collaboration. + +Integrating SIGNL4 with LibreNMS to forward critical alerts with detailed information to responsible people or on-call teams. The integration supports triggering as well as closing alerts. + +In the configuration for your SIGNL4 alert transport you just need to enter your SIGNL4 webhook URL including team or integration secret. + +**Example:** + +| Config | Example | +| ------ | ------- | +| Webhook URL | https://connect.signl4.com/webhook/{team-secret} | + +You can find more information about the integration [here](https://docs.signl4.com/integrations/librenms/librenms.html). + ## Slack The Slack transport will POST the alert message to your Slack Incoming