~dricottone/huttese-apk

f32d2ead9761ee21599d2cf3261abb444e717bf6 — Drew DeVault 4 years ago 228a485
alertmanager-irc-relay: new aport
A sr.ht/alertmanager-irc-relay/APKBUILD => sr.ht/alertmanager-irc-relay/APKBUILD +55 -0
@@ 0,0 1,55 @@
# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=alertmanager-irc-relay
pkgver=20200105
_commit=aebe137d2e9545de98da1959b3036d5a612c8df3
pkgrel=0
pkgdesc="Prometheus Alertmanager IRC relay"
url="https://github.com/google/alertmanager-irc-relay"
arch="all"
license="Apache-2.0"
install="$pkgname.pre-install"
makedepends="go"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/google/alertmanager-irc-relay/archive/$_commit.tar.gz
	alertmanager-irc-relay.confd
	alertmanager-irc-relay.initd
	alertmanager-irc-relay.yml
"
subpackages="$pkgname-openrc"
builddir="$srcdir/$pkgname-$_commit"
options="!check" # requires running IRC server

prepare() {
	go mod init github.com/google/alertmanager-irc-relay
	go mod vendor
}

build() {
	go build \
		-trimpath \
		-mod=vendor \
		-ldflags "-extldflags $LDFLAGS" \
		-tags netgo
}

check() {
	go test ./...
}

package() {
	install -Dm755 alertmanager-irc-relay "$pkgdir"/usr/bin/alertmanager-irc-relay

	install -Dm755 "$srcdir"/alertmanager-irc-relay.initd \
		"$pkgdir"/etc/init.d/alertmanager-irc-relay
	install -Dm644 "$srcdir"/alertmanager-irc-relay.confd \
		"$pkgdir"/etc/conf.d/alertmanager-irc-relay

	mkdir -p "$pkgdir"/etc/alertmanager
	install -Dm644 "$srcdir"/alertmanager-irc-relay.yml \
		"$pkgdir"/etc/alertmanager/alertmanager-irc-relay.yml
}

sha512sums="bb1ecac858cee6403d591a3e600138a12549adcd27f1d3c6136966f163bef9cac697019af0fcd859bc2fd7c6b3ca7bef444d1566559203f7561408fbdd3eeee9  alertmanager-irc-relay-20200105.tar.gz
58f59d1972af10659a5d44f3e005b28928082bac733d27b10238196f68f361cd472782a83b60522c850de7fe9cf502f688956e6e1a2bb64c8aead10dc1529266  alertmanager-irc-relay.confd
92da9c8cdc10ec6cbfb07ae0710b56ab66260bfa78a1f40f0e4ac498cdd50bbbb0ddec2b53d16c1492a77755bfb2382478e22e2e08f0c0e6d421bc206a99e225  alertmanager-irc-relay.initd
646f9241087dd5c595f198b829109c975fb0c637026d59a6a271ae04fe0285744bc527797b171ad3840c543801ebeaad15925f906247de0cf2c86af96b57d9fa  alertmanager-irc-relay.yml"

A sr.ht/alertmanager-irc-relay/alertmanager-irc-relay.confd => sr.ht/alertmanager-irc-relay/alertmanager-irc-relay.confd +2 -0
@@ 0,0 1,2 @@
config_file=/etc/alertmanager/alertmanager.yml
storage_path=/var/lib/alertmanager/data

A sr.ht/alertmanager-irc-relay/alertmanager-irc-relay.initd => sr.ht/alertmanager-irc-relay/alertmanager-irc-relay.initd +16 -0
@@ 0,0 1,16 @@
#!/sbin/openrc-run
name="alertmanager"
description="alert manager for the prometheus monitoring system"
supervisor=supervise-daemon
supervise_daemon_args="-1 /var/log/alertmanager.log -2 /var/log/alertmanager.log"
command=/usr/bin/alertmanager
command_args="--config.file=$config_file \
	--storage.path=$storage_path"
command_user="prometheus:prometheus"
pidfile="/run/${RC_SVCNAME}.pid"

start_pre() {
	checkpath -f "/var/log/alertmanager.initd" -m 644 -o prometheus:prometheus
	checkpath -f "$config_file" -m 740 -o prometheus:prometheus
	checkpath -d "$storage_path" -m 755 -o prometheus:prometheus
}

A sr.ht/alertmanager-irc-relay/alertmanager-irc-relay.pre-install => sr.ht/alertmanager-irc-relay/alertmanager-irc-relay.pre-install +4 -0
@@ 0,0 1,4 @@
#!/bin/sh
grep '^prometheus' /etc/group >/dev/null || addgroup -S prometheus 2>/dev/null
grep '^prometheus' /etc/passwd >/dev/null || adduser -SDh/var/lib/prometheus \
	-s/sbin/nologin -Gprometheus -gprometheus prometheus prometheus 2>/dev/null

A sr.ht/alertmanager-irc-relay/alertmanager-irc-relay.yml => sr.ht/alertmanager-irc-relay/alertmanager-irc-relay.yml +43 -0
@@ 0,0 1,43 @@
# Start the HTTP server receiving alerts from Prometheus Webhook binding to
# this host/port.
#
http_host: localhost
http_port: 8000

# Connect to this IRC host/port.
#
# Note: SSL is enabled by default, use "irc_use_ssl: no" to disable.
irc_host: irc.example.com
irc_port: 7000

# Use this IRC nickname.
irc_nickname: myalertbot
# Password used to identify with NickServ
irc_nickname_password: mynickserv_key
# Use this IRC real name
irc_realname: myrealname

# Optionally pre-join certain channels.
#
# Note: If an alert is sent to a non # pre-joined channel the bot will join
# that channel anyway before sending the notice. Of course this cannot work
# with password-protected channels.
irc_channels:
  - name: "#mychannel"
  - name: "#myprivatechannel"
    password: myprivatechannel_key

# Define how IRC messages should be sent.
#
# Send only one notice when webhook data is received.
# Note: By default a notice is sent for each alert in the webhook data.
notice_once_per_alert_group: no

# Define how IRC messages should be formatted.
#
# The formatting is based on golang's text/template .
notice_template: "Alert {{ .Labels.alertname }} on {{ .Labels.instance }} is {{ .Status }}"
# Note: When sending only one notice per alert group the default
# notice_template is set to
# "Alert {{ .GroupLabels.alertname }} for {{ .GroupLabels.job }} is {{ .Status }}"