Compare commits
No commits in common. "ead3a3637c48e886932a09e3581a7b3ed6512d0d" and "01e99e110ffa506b511fb1ef5541dac45021a4e8" have entirely different histories.
ead3a3637c
...
01e99e110f
13 changed files with 8 additions and 227 deletions
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
cat << EOF
|
|
||||||
Homeserver = "${HOMESERVER:?}"
|
|
||||||
TargetRoomID = "${ROOM_ID:?}"
|
|
||||||
MXID = "${USER_ID:?}"
|
|
||||||
MXToken = "${USER_TOKEN:?}"
|
|
||||||
HTTPPort = ${LISTENING_PORT:?}
|
|
||||||
HTTPAddress = "${LISTENING_HOST:?}"
|
|
||||||
EOF
|
|
|
@ -1,7 +0,0 @@
|
||||||
#!/sbin/openrc-run
|
|
||||||
name="matrix-alertmanager-receiver"
|
|
||||||
description="Forwards Prometheus Alerts to a Matrix room"
|
|
||||||
command=/usr/local/bin/matrix-alertmanager-receiver
|
|
||||||
command_background=true
|
|
||||||
command_user="prometheus:prometheus"
|
|
||||||
pidfile=/run/matrix-alertmanager-receiver.pid
|
|
|
@ -1,11 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Sends Prometheus Alerts to a Matrix room
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=prometheus
|
|
||||||
ExecStart=/usr/local/bin/matrix-alertmanager-receiver
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
|
@ -1,33 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
UPSTREAM=https://git.sr.ht/~fnux/matrix-alertmanager-receiver
|
|
||||||
VERSION=0.1.1
|
|
||||||
|
|
||||||
# Fetch, build and install binary.
|
|
||||||
cat << EOF
|
|
||||||
if ! command -v matrix-alertmanager-receiver; then
|
|
||||||
workdir=\$(mktemp -d)
|
|
||||||
cd \$workdir
|
|
||||||
|
|
||||||
# Fetch source archive.
|
|
||||||
curl "$UPSTREAM/archive/$VERSION.tar.gz" -o "$VERSION.tar.gz"
|
|
||||||
tar xf "$VERSION.tar.gz"
|
|
||||||
cd "matrix-alertmanager-receiver-$VERSION"
|
|
||||||
|
|
||||||
# Build binary.
|
|
||||||
go build -v
|
|
||||||
|
|
||||||
# Install binary.
|
|
||||||
install -m 0755 matrix-alertmanager-receiver /usr/local/bin/
|
|
||||||
|
|
||||||
# Cleanup build directory.
|
|
||||||
rm -r \$workdir
|
|
||||||
|
|
||||||
# Start service.
|
|
||||||
service matrix-alertmanager-receiver start
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if grep -q "^__file/etc/matrix-alertmanager-receiver.toml:" "${__messages_in:?}"; then
|
|
||||||
echo "service matrix-alertmanager-receiver restart"
|
|
||||||
fi
|
|
|
@ -1,70 +0,0 @@
|
||||||
cdist-type__matrix_alertmanager_receiver(7)
|
|
||||||
=====================
|
|
||||||
|
|
||||||
NAME
|
|
||||||
----
|
|
||||||
cdist-type__matrix_alertmanager_receiver - Deploy a simple Prometheus Alertmanager-to-Matrix service
|
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTION
|
|
||||||
-----------
|
|
||||||
This (singleton) type deploys `matrix-alertmanager-receiver <https://git.sr.ht/~fnux/matrix-alertmanager-receiver>`_, a simple daemon allowing Prometheus alerts to be sent to a `Matrix <https://matrix/>`_ room.
|
|
||||||
|
|
||||||
REQUIRED PARAMETERS
|
|
||||||
-------------------
|
|
||||||
homeserver
|
|
||||||
Address of the matrix homeserver to use.
|
|
||||||
|
|
||||||
room-id
|
|
||||||
ID of the (Matrix) room receiving alerts. Note that it must be the room ID:
|
|
||||||
an alias won't work!
|
|
||||||
|
|
||||||
user-id
|
|
||||||
MXID of the (Matrix) user sending alerts.
|
|
||||||
|
|
||||||
user-token
|
|
||||||
Token of the (Matrix) user sending alerts. Can be found under
|
|
||||||
Settings/Advanced in the Element web client.
|
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
|
||||||
-------------------
|
|
||||||
host
|
|
||||||
Host to bind, defaults to `localhost`.
|
|
||||||
|
|
||||||
port
|
|
||||||
Port to listen on, defaults to `9088`.
|
|
||||||
|
|
||||||
BOOLEAN PARAMETERS
|
|
||||||
------------------
|
|
||||||
None.
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
--------
|
|
||||||
|
|
||||||
.. code-block:: sh
|
|
||||||
|
|
||||||
__matrix_alertmanager_receiver \
|
|
||||||
--homeserver 'https://matrix.domain.tld/' \
|
|
||||||
--room-id '!patatra:domain.tld' \
|
|
||||||
--user-id '@alerts:domain.tls' \
|
|
||||||
--user-token 'secretsecretsecret' \
|
|
||||||
--host 'localhost' \
|
|
||||||
--port 9088
|
|
||||||
|
|
||||||
|
|
||||||
SEE ALSO
|
|
||||||
--------
|
|
||||||
- `Upstream <https://git.sr.ht/~fnux/matrix-alertmanager-receiver>`_
|
|
||||||
- `__prometheus_alertmanager(7)`
|
|
||||||
|
|
||||||
AUTHORS
|
|
||||||
-------
|
|
||||||
Timothée Floure <t.floure@e-durable.ch>
|
|
||||||
|
|
||||||
|
|
||||||
COPYING
|
|
||||||
-------
|
|
||||||
Copyright \(C) 2020 Timothée Floure. You can redistribute it
|
|
||||||
and/or modify it under the terms of the GNU General Public License as
|
|
||||||
published by the Free Software Foundation, either version 3 of the
|
|
||||||
License, or (at your option) any later version.
|
|
|
@ -1,65 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
os="$(cat "${__global:?}/explorer/os")"
|
|
||||||
init="$(cat "${__global:?}/explorer/init")"
|
|
||||||
|
|
||||||
case "$os" in
|
|
||||||
alpine)
|
|
||||||
__package go
|
|
||||||
__package prometheus
|
|
||||||
__package curl
|
|
||||||
;;
|
|
||||||
debian|ubuntu)
|
|
||||||
__package golang
|
|
||||||
__package prometheus
|
|
||||||
__package curl
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "This type does not support $os. Exiting." >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Type parameters.
|
|
||||||
HOMESERVER=$(cat "${__object:?}/parameter/homeserver")
|
|
||||||
ROOM_ID=$(cat "${__object:?}/parameter/room-id")
|
|
||||||
USER_ID=$(cat "${__object:?}/parameter/user-id")
|
|
||||||
USER_TOKEN=$(cat "${__object:?}/parameter/user-token")
|
|
||||||
export HOMESERVER ROOM_ID USER_ID USER_TOKEN
|
|
||||||
|
|
||||||
LISTENING_HOST=$(cat "${__object:?}/parameter/host")
|
|
||||||
LISTENING_PORT=$(cat "${__object:?}/parameter/port")
|
|
||||||
export LISTENING_PORT LISTENING_HOST
|
|
||||||
|
|
||||||
# Generate and deploy configuration
|
|
||||||
mkdir -p "${__object:?}/files"
|
|
||||||
"${__type:?}/files/matrix-alertmanager-receiver.toml.sh" > \
|
|
||||||
"${__object:?}/files/matrix-alertmanager-receiver.toml"
|
|
||||||
|
|
||||||
require="__package/prometheus" __file /etc/matrix-alertmanager-receiver.toml \
|
|
||||||
--source "${__object:?}/files/matrix-alertmanager-receiver.toml" \
|
|
||||||
--owner prometheus \
|
|
||||||
--mode 0644
|
|
||||||
|
|
||||||
case "$init" in
|
|
||||||
systemd)
|
|
||||||
unit_path='/etc/systemd/system/matrix-alertmanager-receiver.service'
|
|
||||||
__file "$unit_path" \
|
|
||||||
--source "${__type:?}/files/systemd-unit" \
|
|
||||||
--mode 0644
|
|
||||||
;;
|
|
||||||
busybox-init+openrc)
|
|
||||||
unit_path='/etc/init.d/matrix-alertmanager-receiver'
|
|
||||||
__file "$unit_path" \
|
|
||||||
--source "${__type:?}/files/openrc-unit" \
|
|
||||||
--owner prometheus \
|
|
||||||
--mode 0755
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown init: $init" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
require="__file/$unit_path" \
|
|
||||||
__start_on_boot matrix-alertmanager-receiver
|
|
|
@ -1 +0,0 @@
|
||||||
localhost
|
|
|
@ -1 +0,0 @@
|
||||||
9088
|
|
|
@ -1,2 +0,0 @@
|
||||||
host
|
|
||||||
port
|
|
|
@ -1,4 +0,0 @@
|
||||||
homeserver
|
|
||||||
room-id
|
|
||||||
user-id
|
|
||||||
user-token
|
|
|
@ -3,31 +3,17 @@
|
||||||
os="$(cat "${__global:?}/explorer/os")"
|
os="$(cat "${__global:?}/explorer/os")"
|
||||||
case "$os" in
|
case "$os" in
|
||||||
alpine)
|
alpine)
|
||||||
config=/etc/blackbox_exporter/blackbox.yml
|
__package blackbox_exporter
|
||||||
package=blackbox_exporter
|
require="__package/blackbox_exporter" __start_on_boot \
|
||||||
service="$package"
|
blackbox_exporter
|
||||||
|
require="__package/blackbox_exporter" __service \
|
||||||
|
blackbox_exporter --action start
|
||||||
|
;;
|
||||||
|
debian|ubuntu)
|
||||||
|
__package prometheus-blackbox-exporter
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "This type does not supper $os. Exiting." >&2
|
echo "This type does not supper $os. Exiting." >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Install software.
|
|
||||||
__package "$package"
|
|
||||||
require="__package/$package" __start_on_boot "$service"
|
|
||||||
require="__package/$package" __service "$service" --action start
|
|
||||||
|
|
||||||
if [ -f "${__object:?}/parameter/config" ]; then
|
|
||||||
if [ "$(cat "${__object:?}/parameter/config")" = "-" ]; then
|
|
||||||
user_config="${__object:?}/stdin"
|
|
||||||
else
|
|
||||||
user_config="${__object:?}/parameter/config"
|
|
||||||
fi
|
|
||||||
|
|
||||||
require="__package/$package" __file "$config" \
|
|
||||||
--source "$user_config" \
|
|
||||||
--mode 0644 \
|
|
||||||
--owner root \
|
|
||||||
--onchange "service $service restart"
|
|
||||||
fi
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
config
|
|
Reference in a new issue