Add new __unbound_exporter type
This commit is contained in:
parent
7b9ffb4a41
commit
1e45d85d4d
6 changed files with 166 additions and 0 deletions
12
type/__unbound_exporter/files/openrc-service
Normal file
12
type/__unbound_exporter/files/openrc-service
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
name=$RC_SVCNAME
|
||||
command="/usr/local/bin/unbound_exporter"
|
||||
command_args=""
|
||||
command_user="unbound"
|
||||
command_background="yes"
|
||||
pidfile="/var/run/$RC_SVCNAME.pid"
|
||||
|
||||
depend() {
|
||||
need unbound
|
||||
}
|
46
type/__unbound_exporter/gencode-remote
Executable file
46
type/__unbound_exporter/gencode-remote
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2020 Timothée Floure (timothee.floure@ungleich.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: 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.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
upstream=https://github.com/wish/unbound_exporter/archive
|
||||
version=$(cat $__object/parameter/version)
|
||||
release="unbound_exporter-$version"
|
||||
|
||||
cat << EOF
|
||||
if command -v unbound_exporter
|
||||
then
|
||||
# already installed - ignoring.
|
||||
echo "Nothing to do -"
|
||||
else
|
||||
# Initialize working directory
|
||||
workdir=\$(mktemp -d)
|
||||
cd \$workdir
|
||||
|
||||
# Download and extract sources for requested release.
|
||||
curl -L $upstream/v$version.tar.gz --output $release.tar.gz
|
||||
tar xf $release.tar.gz
|
||||
|
||||
# Build and install binary.
|
||||
cd $release
|
||||
go build
|
||||
install -m755 unbound_exporter /usr/local/bin/
|
||||
|
||||
# Clean up!
|
||||
rm -r \$workdir
|
||||
fi
|
||||
EOF
|
63
type/__unbound_exporter/man.rst
Normal file
63
type/__unbound_exporter/man.rst
Normal file
|
@ -0,0 +1,63 @@
|
|||
cdist-type__unbound_exporter(7)
|
||||
===============================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__unbound_exporter - A prometheus exporter for unbound
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Simple Prometheus metrics exporter for the Unbound DNS
|
||||
resolver. It leverages the unbound remote control endpoint
|
||||
and exposes metrics on port 9167.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
version
|
||||
unbound_exporter release to be used.
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
None.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
__unbound \
|
||||
--interface '::0' \
|
||||
--forward_addr '2a0a:e5c0:2:1::5' \
|
||||
--forward_addr '2a0a:e5c0:2:1::6' \
|
||||
--access_control '::0/0 deny' \
|
||||
--access_control '2a0a:e5c0::/29 allow' \
|
||||
--access_control '2a09:2940::/29 allow' \
|
||||
--disable_ip4 \
|
||||
--enable_rc \
|
||||
--rc_interface '::1'
|
||||
|
||||
__unbound_exporter --version 0.1.3
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
:strong:`cdist-type__unbound(7)`
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Timothée Floure <timothee.floure@ungleich.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.
|
44
type/__unbound_exporter/manifest
Executable file
44
type/__unbound_exporter/manifest
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2020 Timothée Floure (timothee.floure@ungleich.ch)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: 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.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
os=$(cat "$__global/explorer/os")
|
||||
|
||||
case "$os" in
|
||||
alpine)
|
||||
# Used in gencode-remote.
|
||||
__package curl
|
||||
__package tar
|
||||
__package go
|
||||
__package libc-dev
|
||||
;;
|
||||
*)
|
||||
printf "Your operating system (%s) is currently not supported by this type (%s)\n" "$os" "${__type##*/}" >&2
|
||||
printf "Please contribute an implementation for it if you can.\n" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
__file /etc/init.d/unbound_exporter \
|
||||
--source "$__type/files/openrc-service" \
|
||||
--mode 755
|
||||
|
||||
require="__file/etc/init.d/unbound_exporter" __service unbound_exporter --action start
|
||||
require="__file/etc/init.d/unbound_exporter" __start_on_boot unbound_exporter
|
1
type/__unbound_exporter/parameter/required
Normal file
1
type/__unbound_exporter/parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
version
|
0
type/__unbound_exporter/singleton
Normal file
0
type/__unbound_exporter/singleton
Normal file
Loading…
Reference in a new issue