summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRahil Bhimjiani <rahil3108@gmail.com>2023-10-01 22:09:42 +0530
committerSam James <sam@gentoo.org>2023-11-23 12:38:29 +0000
commite08275b72c23fd6ab1b4c4a9960a4e8b46105301 (patch)
tree48b11419c46c8e07911615d6dea0cea048055978 /app-metrics
parentapp-containers/skopeo: add live & 1.14.0 (diff)
downloadgentoo-e08275b72c23fd6ab1b4c4a9960a4e8b46105301.tar.gz
gentoo-e08275b72c23fd6ab1b4c4a9960a4e8b46105301.tar.bz2
gentoo-e08275b72c23fd6ab1b4c4a9960a4e8b46105301.zip
app-metrics/node_exporter: add 1.7.0 and live
1. Added a patch from debian which removes deprecated legacy pre-1.0 era stuff 2. Added logrotate config 3. added systemd unit file with improvements 4. new use flag - systemd. When enabled it enables systemd collector by default 5. install manpage (which was not the case before) 6. Add essential docs and examples 7. split LICENSE 8. follow skel.ebuild for {R,,B}DEPEND [sam: Maintainer timeout after pings on IRC and in the bug.] Closes: https://bugs.gentoo.org/915505 Signed-off-by: Rahil Bhimjiani <rahil3108@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'app-metrics')
-rw-r--r--app-metrics/node_exporter/Manifest2
-rw-r--r--app-metrics/node_exporter/files/01-default-settings-1.7.0.patch133
-rw-r--r--app-metrics/node_exporter/files/node_exporter-1.7.0.logrotate9
-rw-r--r--app-metrics/node_exporter/files/node_exporter-1.7.0.service21
-rw-r--r--app-metrics/node_exporter/metadata.xml15
-rw-r--r--app-metrics/node_exporter/node_exporter-1.7.0.ebuild74
-rw-r--r--app-metrics/node_exporter/node_exporter-9999.ebuild74
7 files changed, 328 insertions, 0 deletions
diff --git a/app-metrics/node_exporter/Manifest b/app-metrics/node_exporter/Manifest
index 50ef50db5892..147b0122a53c 100644
--- a/app-metrics/node_exporter/Manifest
+++ b/app-metrics/node_exporter/Manifest
@@ -4,3 +4,5 @@ DIST node_exporter-1.4.0-deps.tar.xz 24623388 BLAKE2B 76ea5392f3f4ee2d76706d7762
DIST node_exporter-1.4.0.tar.gz 325743 BLAKE2B df6af555035c70930a610790e8d5eee87ca12cd27308ed95edf875da8615b61dde805d960d6262587322abecb721695bd42b1c078a7bcc40b24053cfce86015d SHA512 ebb4f9662ba995130b96e108050571119da368a8195e50896a19aab04d7cb40d60f9ae81052a0de08f571886cfb4150bf006a7b67a3d3683f2d04b5f43d61e7a
DIST node_exporter-1.5.0-deps.tar.xz 25558844 BLAKE2B fd862394c4e9456af395af4a1a8fb5c9504b96fcfa5170027903edadcf29935ffa389a945a8306e59e8d373b238481090e61dca4d9b037d890e8df05a5c8ede7 SHA512 5141beabd6f6af57014d2095271ea7c9a7e6087d9939cf6fc4a89908df0a5b87267f469987d47b20a48411d5a01a1317c53bfad8138dcfa6aa80c0a9f3822aa7
DIST node_exporter-1.5.0.tar.gz 329004 BLAKE2B 650e176ce15be980f9a3534f3246b577390d6d557b0ac7aa5341f3c91390bed829c4c3c3f60a4c108c814945134dc83639e12a13f416471e9c791ec88ed8a7bd SHA512 5b6d1da70a3458a1de270bcaf6ab177bd41c8b7031e67a4691b0b79931d15f0e22dbe1533f1ff0474496fcf4433bbd4b3473b8c0063f8891456960d7b6f56e15
+DIST node_exporter-1.7.0-deps.tar.xz 26490120 BLAKE2B 3177aa96a50eefaeafad73b293144772443428b8c1b90210230e3e508a678f5515aebec1c51661d47a1e021cd03c8febe9aa948cc3d955eff2b2f272a539b6af SHA512 9fe19ad0fc375f4846fddb7618de5b34ddad583b5c6b09d896c099c3218976fd337c11765699a713c66bbaa834b6cfcaee960b1b1d4014be263b99b897fb1e1c
+DIST node_exporter-1.7.0.tar.gz 328830 BLAKE2B 5f6b8101637bc0df605ea84446f905fcf8abeb68d0f2eda1e172b12aae4cffcfef54996f8725ad458671947c72a48fbbd73d4d401d8fd001e9e9d75f248230fc SHA512 4cd38b81cb54ca620a57c642a88b89d6d1ae36a752fff5f065c8848ea02066a211c6feb955bea4e311f7baafffee30a74670efe1cf4dac113c9bf7d154a1067b
diff --git a/app-metrics/node_exporter/files/01-default-settings-1.7.0.patch b/app-metrics/node_exporter/files/01-default-settings-1.7.0.patch
new file mode 100644
index 000000000000..114c6d23423e
--- /dev/null
+++ b/app-metrics/node_exporter/files/01-default-settings-1.7.0.patch
@@ -0,0 +1,133 @@
+Grabbed from https://salsa.debian.org/go-team/packages/prometheus-node-exporter/-/tree/debian/sid/debian/patches
+Only thing changed is textFileDirectory default path adapted for Gentoo
+##############
+Description: Set defaults that make sense for Debian systems.
+ We remove the deprecated options completely because they were introduced in
+ 1.0.0 and were never part of a stable release, and are causing issues with
+ the default value setting as it then makes the code consider it a usage and
+ errors out when the legacy option is used.
+Forwarded: not-needed
+---
+ collector/filesystem_linux.go | 2 +-
+ collector/netdev_common.go | 22 +---------------------
+ collector/systemd_linux.go | 23 ++---------------------
+ collector/textfile.go | 2 +-
+ 4 files changed, 5 insertions(+), 44 deletions(-)
+
+--- a/collector/filesystem_linux.go
++++ b/collector/filesystem_linux.go
+@@ -33,7 +33,7 @@ import (
+ )
+
+ const (
+- defMountPointsExcluded = "^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+|var/lib/containers/storage/.+)($|/)"
++ defMountPointsExcluded = "^/(dev|proc|run|sys|mnt|media|var/lib/docker/.+|var/lib/containers/storage/.+)($|/)"
+ defFSTypesExcluded = "^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
+ )
+
+--- a/collector/netdev_common.go
++++ b/collector/netdev_common.go
+@@ -32,9 +32,7 @@ import (
+
+ var (
+ netdevDeviceInclude = kingpin.Flag("collector.netdev.device-include", "Regexp of net devices to include (mutually exclusive to device-exclude).").String()
+- oldNetdevDeviceInclude = kingpin.Flag("collector.netdev.device-whitelist", "DEPRECATED: Use collector.netdev.device-include").Hidden().String()
+- netdevDeviceExclude = kingpin.Flag("collector.netdev.device-exclude", "Regexp of net devices to exclude (mutually exclusive to device-include).").String()
+- oldNetdevDeviceExclude = kingpin.Flag("collector.netdev.device-blacklist", "DEPRECATED: Use collector.netdev.device-exclude").Hidden().String()
++ netdevDeviceExclude = kingpin.Flag("collector.netdev.device-exclude", "Regexp of net devices to exclude (mutually exclusive to device-include).").Default("^lo$").String()
+ netdevAddressInfo = kingpin.Flag("collector.netdev.address-info", "Collect address-info for every device").Bool()
+ netdevDetailedMetrics = kingpin.Flag("collector.netdev.enable-detailed-metrics", "Use (incompatible) metric names that provide more detailed stats on Linux").Bool()
+ )
+@@ -55,24 +53,6 @@ func init() {
+
+ // NewNetDevCollector returns a new Collector exposing network device stats.
+ func NewNetDevCollector(logger log.Logger) (Collector, error) {
+- if *oldNetdevDeviceInclude != "" {
+- if *netdevDeviceInclude == "" {
+- level.Warn(logger).Log("msg", "--collector.netdev.device-whitelist is DEPRECATED and will be removed in 2.0.0, use --collector.netdev.device-include")
+- *netdevDeviceInclude = *oldNetdevDeviceInclude
+- } else {
+- return nil, errors.New("--collector.netdev.device-whitelist and --collector.netdev.device-include are mutually exclusive")
+- }
+- }
+-
+- if *oldNetdevDeviceExclude != "" {
+- if *netdevDeviceExclude == "" {
+- level.Warn(logger).Log("msg", "--collector.netdev.device-blacklist is DEPRECATED and will be removed in 2.0.0, use --collector.netdev.device-exclude")
+- *netdevDeviceExclude = *oldNetdevDeviceExclude
+- } else {
+- return nil, errors.New("--collector.netdev.device-blacklist and --collector.netdev.device-exclude are mutually exclusive")
+- }
+- }
+-
+ if *netdevDeviceExclude != "" && *netdevDeviceInclude != "" {
+ return nil, errors.New("device-exclude & device-include are mutually exclusive")
+ }
+--- a/collector/systemd_linux.go
++++ b/collector/systemd_linux.go
+@@ -18,7 +18,6 @@ package collector
+
+ import (
+ "context"
+- "errors"
+ "fmt"
+ "math"
+ "regexp"
+@@ -47,13 +46,11 @@ var (
+ systemdUnitIncludeSet = true
+ return nil
+ }).String()
+- oldSystemdUnitInclude = kingpin.Flag("collector.systemd.unit-whitelist", "DEPRECATED: Use --collector.systemd.unit-include").Hidden().String()
+ systemdUnitExcludeSet bool
+- systemdUnitExclude = kingpin.Flag("collector.systemd.unit-exclude", "Regexp of systemd units to exclude. Units must both match include and not match exclude to be included.").Default(".+\\.(automount|device|mount|scope|slice)").PreAction(func(c *kingpin.ParseContext) error {
++ systemdUnitExclude = kingpin.Flag("collector.systemd.unit-exclude", "Regexp of systemd units to exclude. Units must both match include and not match exclude to be included.").Default(".+\\.(automount|device|mount|scope|slice|target)").PreAction(func(c *kingpin.ParseContext) error {
+ systemdUnitExcludeSet = true
+ return nil
+ }).String()
+- oldSystemdUnitExclude = kingpin.Flag("collector.systemd.unit-blacklist", "DEPRECATED: Use collector.systemd.unit-exclude").Hidden().String()
+ systemdPrivate = kingpin.Flag("collector.systemd.private", "Establish a private, direct connection to systemd without dbus (Strongly discouraged since it requires root. For testing purposes only).").Hidden().Bool()
+ enableTaskMetrics = kingpin.Flag("collector.systemd.enable-task-metrics", "Enables service unit tasks metrics unit_tasks_current and unit_tasks_max").Bool()
+ enableRestartsMetrics = kingpin.Flag("collector.systemd.enable-restarts-metrics", "Enables service unit metric service_restart_total").Bool()
+@@ -83,7 +80,7 @@ type systemdCollector struct {
+ var unitStatesName = []string{"active", "activating", "deactivating", "inactive", "failed"}
+
+ func init() {
+- registerCollector("systemd", defaultDisabled, NewSystemdCollector)
++ registerCollector("systemd", defaultEnabled, NewSystemdCollector)
+ }
+
+ // NewSystemdCollector returns a new Collector exposing systemd statistics.
+@@ -133,22 +130,6 @@ func NewSystemdCollector(logger log.Logg
+ prometheus.BuildFQName(namespace, subsystem, "version"),
+ "Detected systemd version", []string{"version"}, nil)
+
+- if *oldSystemdUnitExclude != "" {
+- if !systemdUnitExcludeSet {
+- level.Warn(logger).Log("msg", "--collector.systemd.unit-blacklist is DEPRECATED and will be removed in 2.0.0, use --collector.systemd.unit-exclude")
+- *systemdUnitExclude = *oldSystemdUnitExclude
+- } else {
+- return nil, errors.New("--collector.systemd.unit-blacklist and --collector.systemd.unit-exclude are mutually exclusive")
+- }
+- }
+- if *oldSystemdUnitInclude != "" {
+- if !systemdUnitIncludeSet {
+- level.Warn(logger).Log("msg", "--collector.systemd.unit-whitelist is DEPRECATED and will be removed in 2.0.0, use --collector.systemd.unit-include")
+- *systemdUnitInclude = *oldSystemdUnitInclude
+- } else {
+- return nil, errors.New("--collector.systemd.unit-whitelist and --collector.systemd.unit-include are mutually exclusive")
+- }
+- }
+ level.Info(logger).Log("msg", "Parsed flag --collector.systemd.unit-include", "flag", *systemdUnitInclude)
+ systemdUnitIncludePattern := regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *systemdUnitInclude))
+ level.Info(logger).Log("msg", "Parsed flag --collector.systemd.unit-exclude", "flag", *systemdUnitExclude)
+--- a/collector/textfile.go
++++ b/collector/textfile.go
+@@ -33,7 +33,7 @@ import (
+ )
+
+ var (
+- textFileDirectory = kingpin.Flag("collector.textfile.directory", "Directory to read text files with metrics from.").Default("").String()
++ textFileDirectory = kingpin.Flag("collector.textfile.directory", "Directory to read text files with metrics from.").Default("/var/lib/node_exporter").String()
+ mtimeDesc = prometheus.NewDesc(
+ "node_textfile_mtime_seconds",
+ "Unixtime mtime of textfiles successfully read.",
diff --git a/app-metrics/node_exporter/files/node_exporter-1.7.0.logrotate b/app-metrics/node_exporter/files/node_exporter-1.7.0.logrotate
new file mode 100644
index 000000000000..82cad3ace322
--- /dev/null
+++ b/app-metrics/node_exporter/files/node_exporter-1.7.0.logrotate
@@ -0,0 +1,9 @@
+/var/log/node_exporter/node_exporter.log {
+ weekly
+ rotate 10
+ copytruncate
+ compress
+ delaycompress
+ notifempty
+ missingok
+}
diff --git a/app-metrics/node_exporter/files/node_exporter-1.7.0.service b/app-metrics/node_exporter/files/node_exporter-1.7.0.service
new file mode 100644
index 000000000000..e704c809b8e5
--- /dev/null
+++ b/app-metrics/node_exporter/files/node_exporter-1.7.0.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=Prometheus exporter for machine metrics
+Documentation=https://github.com/prometheus/node_exporter
+Requires=network-online.target
+After=network-online.target
+
+[Service]
+User=node_exporter
+Group=node_exporter
+Restart=on-failure
+Type=exec
+ExecStart=/usr/sbin/node_exporter
+ExecReload=/usr/bin/kill -HUP $MAINPID
+TimeoutStopSec=20s
+SendSIGKILL=no
+NoNewPrivileges=true
+ProtectHome=read-only
+ProtectSystem=strict
+
+[Install]
+WantedBy=multi-user.target
diff --git a/app-metrics/node_exporter/metadata.xml b/app-metrics/node_exporter/metadata.xml
index 080050c2eb9d..e4512038e885 100644
--- a/app-metrics/node_exporter/metadata.xml
+++ b/app-metrics/node_exporter/metadata.xml
@@ -5,7 +5,22 @@
<email>williamh@gentoo.org</email>
<name>William Hubbs</name>
</maintainer>
+ <maintainer type="person" proxied="yes">
+ <email>rahil3108@gmail.com</email>
+ <name>Rahil Bhimjiani</name>
+ </maintainer>
+ <maintainer type="project" proxied="proxy">
+ <email>proxy-maint@gentoo.org</email>
+ <name>Proxy Maintainers</name>
+ </maintainer>
+ <use>
+ <flag name="systemd">
+ Enables systemd collector by default
+ </flag>
+ </use>
<upstream>
<remote-id type="github">prometheus/node_exporter</remote-id>
+ <bugs-to>https://github.com/prometheus/node_exporter/issues</bugs-to>
+ <doc>https://github.com/prometheus/node_exporter/blob/master/README.md</doc>
</upstream>
</pkgmetadata>
diff --git a/app-metrics/node_exporter/node_exporter-1.7.0.ebuild b/app-metrics/node_exporter/node_exporter-1.7.0.ebuild
new file mode 100644
index 000000000000..e02032dc5f61
--- /dev/null
+++ b/app-metrics/node_exporter/node_exporter-1.7.0.ebuild
@@ -0,0 +1,74 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit go-module systemd
+
+DESCRIPTION="Prometheus exporter for machine metrics"
+HOMEPAGE="https://github.com/prometheus/node_exporter"
+
+if [[ ${PV} == 9999* ]]; then
+ inherit git-r3
+ EGIT_REPO_URI="https://github.com/prometheus/node_exporter.git"
+else
+ SRC_URI="https://github.com/prometheus/node_exporter/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+ SRC_URI+=" https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz -> ${P}-deps.tar.xz"
+ KEYWORDS="~amd64 ~arm64 ~loong ~riscv ~x86"
+fi
+
+# main pkg
+LICENSE="Apache-2.0"
+# deps
+LICENSE+=" BSD BSD-2 MIT"
+SLOT="0"
+IUSE="selinux systemd"
+
+RDEPEND="
+ acct-group/node_exporter
+ acct-user/node_exporter
+ selinux? ( sec-policy/selinux-node_exporter )
+ systemd? ( sys-apps/systemd )
+"
+DEPEND="${RDEPEND}"
+BDEPEND=">=dev-util/promu-0.3.0"
+PATCHES=(
+ "${FILESDIR}"/01-default-settings-1.7.0.patch
+)
+
+src_prepare() {
+ default
+ use !systemd && { sed -i -e "s|defaultEnabled|defaultDisabled|g;" collector/systemd_linux.go || die; }
+}
+
+src_unpack() {
+ if [[ ${PV} == 9999* ]]; then
+ git-r3_src_unpack
+ go-module_live_vendor
+ else
+ go-module_src_unpack
+ fi
+}
+
+src_compile() {
+ promu build -v || die
+ ./"${PN}" --help-man > "${PN}".1 || die
+}
+
+src_test() {
+ emake test-flags= test
+}
+
+src_install() {
+ dosbin "${PN}"
+ systemd_newunit "${FILESDIR}"/node_exporter-1.7.0.service node_exporter.service
+ newinitd "${FILESDIR}"/${PN}.initd-1 ${PN}
+ newconfd "${FILESDIR}"/${PN}.confd ${PN}
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}"/node_exporter-1.7.0.logrotate "${PN}"
+ keepdir /var/lib/node_exporter /var/log/node_exporter
+ fowners ${PN}:${PN} /var/lib/node_exporter /var/log/node_exporter
+
+ doman "${PN}".1
+ dodoc example-rules.yml *.md
+}
diff --git a/app-metrics/node_exporter/node_exporter-9999.ebuild b/app-metrics/node_exporter/node_exporter-9999.ebuild
new file mode 100644
index 000000000000..e02032dc5f61
--- /dev/null
+++ b/app-metrics/node_exporter/node_exporter-9999.ebuild
@@ -0,0 +1,74 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit go-module systemd
+
+DESCRIPTION="Prometheus exporter for machine metrics"
+HOMEPAGE="https://github.com/prometheus/node_exporter"
+
+if [[ ${PV} == 9999* ]]; then
+ inherit git-r3
+ EGIT_REPO_URI="https://github.com/prometheus/node_exporter.git"
+else
+ SRC_URI="https://github.com/prometheus/node_exporter/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+ SRC_URI+=" https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz -> ${P}-deps.tar.xz"
+ KEYWORDS="~amd64 ~arm64 ~loong ~riscv ~x86"
+fi
+
+# main pkg
+LICENSE="Apache-2.0"
+# deps
+LICENSE+=" BSD BSD-2 MIT"
+SLOT="0"
+IUSE="selinux systemd"
+
+RDEPEND="
+ acct-group/node_exporter
+ acct-user/node_exporter
+ selinux? ( sec-policy/selinux-node_exporter )
+ systemd? ( sys-apps/systemd )
+"
+DEPEND="${RDEPEND}"
+BDEPEND=">=dev-util/promu-0.3.0"
+PATCHES=(
+ "${FILESDIR}"/01-default-settings-1.7.0.patch
+)
+
+src_prepare() {
+ default
+ use !systemd && { sed -i -e "s|defaultEnabled|defaultDisabled|g;" collector/systemd_linux.go || die; }
+}
+
+src_unpack() {
+ if [[ ${PV} == 9999* ]]; then
+ git-r3_src_unpack
+ go-module_live_vendor
+ else
+ go-module_src_unpack
+ fi
+}
+
+src_compile() {
+ promu build -v || die
+ ./"${PN}" --help-man > "${PN}".1 || die
+}
+
+src_test() {
+ emake test-flags= test
+}
+
+src_install() {
+ dosbin "${PN}"
+ systemd_newunit "${FILESDIR}"/node_exporter-1.7.0.service node_exporter.service
+ newinitd "${FILESDIR}"/${PN}.initd-1 ${PN}
+ newconfd "${FILESDIR}"/${PN}.confd ${PN}
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}"/node_exporter-1.7.0.logrotate "${PN}"
+ keepdir /var/lib/node_exporter /var/log/node_exporter
+ fowners ${PN}:${PN} /var/lib/node_exporter /var/log/node_exporter
+
+ doman "${PN}".1
+ dodoc example-rules.yml *.md
+}