first commit

This commit is contained in:
yo 2020-08-06 23:06:53 +02:00
commit fc2afd9cf7
7 changed files with 157 additions and 0 deletions

44
Makefile Normal file
View File

@ -0,0 +1,44 @@
# $FreeBSD: head/sysutils/postfix_exporter/Makefile 517745 2019-11-16 12:52:39Z dmgk $
PORTNAME= postfix_exporter
PORTVERSION= 0.2.0
PORTREVISION= 1
CATEGORIES= sysutils
MAINTAINER= yo@nosd.in
COMMENT= Export postfix metrics in Prometheus format
LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE
USES= go
USE_GITHUB= yes
GH_ACCOUNT= kumina
GH_PROJECT= postfix_exporter
USERS= postfix_exporter
GROUPS= maildrop
GH_TUPLE= alecthomas:kingpin:v2.2.6:kingpin/vendor/github.com/alecthomas/kingpin \
alecthomas:template:fb15b89:template/vendor/github.com/alecthomas/template \
alecthomas:units:f65c72e:units/vendor/github.com/alecthomas/units \
beorn7:perks:v1.0.0:perks/vendor/github.com/beorn7/perks \
cespare:xxhash:v2.1.1:xxhash/vendor/github.com/cespare/xxhash/v2 \
golang:protobuf:v1.3.1:protobuf/vendor/github.com/golang/protobuf \
golang:sys:5ac8a444bdc5:sys/vendor/golang.org/x/sys \
hpcloud:tail:v1.0.0:tail/vendor/github.com/hpcloud/tail \
matttproud:golang_protobuf_extensions:v1.0.1:golang_protobuf_extensions/vendor/github.com/matttproud/golang_protobuf_extensions \
prometheus:client_golang:v1.6.0:client_golang/vendor/github.com/prometheus/client_golang \
prometheus:client_model:v0.2.0:client_model/vendor/github.com/prometheus/client_model \
prometheus:common:v0.10.0:common/vendor/github.com/prometheus/common \
prometheus:procfs:v0.0.11:procfs/vendor/github.com/prometheus/procfs
GO_PKGNAME= github.com/${GH_ACCOUNT}/${GH_PROJECT}
GO_BUILDFLAGS= -tags nosystemd
USE_RC_SUBR= postfix_exporter
pre-test:
${SETENV} GOPATH="${WRKDIR}"
.include <bsd.port.mk>

29
distinfo Normal file
View File

@ -0,0 +1,29 @@
TIMESTAMP = 1591295100
SHA256 (kumina-postfix_exporter-0.2.0_GH0.tar.gz) = 2b39a80e514e43ce7bcea4a7c99500e9bc875b228daf777b43e34c7198d91ef8
SIZE (kumina-postfix_exporter-0.2.0_GH0.tar.gz) = 12119
SHA256 (alecthomas-kingpin-v2.2.6_GH0.tar.gz) = 4624eae43489de8a71ea60efaf6744c581b6bd62909f7514c484c1ea0efaba5a
SIZE (alecthomas-kingpin-v2.2.6_GH0.tar.gz) = 44383
SHA256 (alecthomas-template-fb15b89_GH0.tar.gz) = edc515063323c61120740ef930ce60e659e9ae82e2b21062ec451ff675b8d6be
SIZE (alecthomas-template-fb15b89_GH0.tar.gz) = 55333
SHA256 (alecthomas-units-f65c72e_GH0.tar.gz) = ea7b78bc113b977f2cb2a52cf7bb46dc2e61476b13a8ae7ab6ce79883a69b0a5
SIZE (alecthomas-units-f65c72e_GH0.tar.gz) = 4920
SHA256 (beorn7-perks-v1.0.0_GH0.tar.gz) = b69d92e2e84b7d510dfa6110d3ac4ada0096a6c81190c5e174aa888bfe475cbc
SIZE (beorn7-perks-v1.0.0_GH0.tar.gz) = 10866
SHA256 (cespare-xxhash-v2.1.1_GH0.tar.gz) = 0ee31178d2c5a1249be4e26294a2f428008dc4e1ecbbfbe47f74e41026df1148
SIZE (cespare-xxhash-v2.1.1_GH0.tar.gz) = 9292
SHA256 (golang-protobuf-v1.3.1_GH0.tar.gz) = 3f3a6123054a9847093c119895f1660612f301fe95358f3a6a1a33fd0933e6cf
SIZE (golang-protobuf-v1.3.1_GH0.tar.gz) = 310884
SHA256 (golang-sys-5ac8a444bdc5_GH0.tar.gz) = 1d94fa910156b4c897b28dba696f29ecb0ef67d8f1f9626588bec21350e29c13
SIZE (golang-sys-5ac8a444bdc5_GH0.tar.gz) = 1110515
SHA256 (hpcloud-tail-v1.0.0_GH0.tar.gz) = 3aa982c4a779b1c1dc5723bbf2345eed1dd46cd5bcc490e69de4beab8f5d4b02
SIZE (hpcloud-tail-v1.0.0_GH0.tar.gz) = 37816
SHA256 (matttproud-golang_protobuf_extensions-v1.0.1_GH0.tar.gz) = 2def0ee6f6b12b1efc0e3007d89f598608a072610e805c3655ea9d13c3ead49b
SIZE (matttproud-golang_protobuf_extensions-v1.0.1_GH0.tar.gz) = 37184
SHA256 (prometheus-client_golang-v1.6.0_GH0.tar.gz) = e255f632b7223f794e0f60d99976535c16153cc00fadf39ee87fd9f678d6a32c
SIZE (prometheus-client_golang-v1.6.0_GH0.tar.gz) = 157355
SHA256 (prometheus-client_model-v0.2.0_GH0.tar.gz) = 4ab1be9cdfa702d7f49beeb09a256bcc6a2aad55e8a0a37e7732a46934264e12
SIZE (prometheus-client_model-v0.2.0_GH0.tar.gz) = 10986
SHA256 (prometheus-common-v0.10.0_GH0.tar.gz) = 349381082ea8e66637c2d2475f1ae0e74ca04a7b91eb3b96817c261b87668fd3
SIZE (prometheus-common-v0.10.0_GH0.tar.gz) = 107763
SHA256 (prometheus-procfs-v0.0.11_GH0.tar.gz) = fd84664db471a0d08d721abc383665fe9a61a56001ff2c8b3b3734f8146bf0ae
SIZE (prometheus-procfs-v0.0.11_GH0.tar.gz) = 135114

View File

@ -0,0 +1,19 @@
--- postfix_exporter.go.orig 2019-02-15 11:41:28 UTC
+++ postfix_exporter.go
@@ -31,6 +31,7 @@ import (
"github.com/hpcloud/tail"
"github.com/prometheus/client_golang/prometheus"
+ "github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
@@ -691,7 +692,7 @@ func main() {
}
prometheus.MustRegister(exporter)
- http.Handle(*metricsPath, prometheus.Handler())
+ http.Handle(*metricsPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
_, err = w.Write([]byte(`
<html>

45
files/postfix_exporter.in Normal file
View File

@ -0,0 +1,45 @@
#!/bin/sh
# $FreeBSD: head/net/postfix_exporter/files/postfix_exporter.in 529909 2020-03-30 19:18:03Z decke $
#
# PROVIDE: postfix_exporter
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# postfix_exporter_enable (bool): Set to "YES" to enable postfix_exporter.
# (default: "NO")
#
# postfix_exporter_postfix_logfile (str): File where Postfix writes log entries.
# Will be truncated by the exporter.
# (default: "/var/log/maillog")
# postfix_exporter_showq (str): Showq socket path
# (default: "/var/spool/postfix/public/showq")
# postfix_exporter_listen (str): Exporter listening address
# (default: ":9154")
# postfix_exporter_telemetry_path (str): Path under which to expose metrics
# (default: "/metrics")
# postfix_exporter_logfile (str): Postfix_exporter logfile
# (default: "/var/log/postfix_exporter.log")
#
. /etc/rc.subr
name=postfix_exporter
rcvar=postfix_exporter_enable
load_rc_config $name
: ${postfix_exporter_enable="NO"}
: ${postfix_exporter_postfix_logfile="/var/log/maillog"}
: ${postfix_exporter_showq="/var/spool/postfix/public/showq"}
: ${postfix_exporter_listen=":9154"}
: ${postfix_exporter_telemetry_path="/metrics"}
: ${postfix_exporter_pidfile:="/var/run/postfix_exporter.pid"}
: ${postfix_exporter_user:="postfix_exporter"}
: ${postfix_exporter_logfile="/var/log/postfix_exporter.log"}
command="/usr/local/bin/postfix_exporter"
command_args="--web.listen-address=\${postfix_exporter_listen} --web.telemetry-path=\${postfix_exporter_telemetry_path} --postfix.showq_path=\${postfix_exporter_showq} --postfix.logfile_path=\${postfix_exporter_postfix_logfile} > ${postfix_exporter_logfile} 2>&1"
start_cmd="/usr/sbin/daemon -u ${postfix_exporter_user} ${command} ${command_args}"
run_rc_command "$1"

3
pkg-descr Normal file
View File

@ -0,0 +1,3 @@
Export postfix metrics in Prometheus format.
WWW: https://github.com/kumina/postfix_exporter

15
pkg-message Normal file
View File

@ -0,0 +1,15 @@
[
{ type: install
message: <<EOM
For postfix_exporter to read maillog, you need to chown it to maildrop group:
chown :maildrop /var/log/maillog
Also configure newsyslog to apply these rights when rotating log:
/var/log/maillog root:maildrop 640 7 * @T00 JC
Create postfix_exporter logfile with:
touch /var/log/postfix_exporter.log && chown postfix_exporter /var/log/postfix_exporter.log
EOM
}
]

2
pkg-plist Normal file
View File

@ -0,0 +1,2 @@
bin/postfix_exporter
etc/rc.d/postfix_exporter