Merge branch 'prometheus-cpu-mem-monitor' of linux/gentoo-overlay into master
This commit is contained in:
commit
bb5bbd9c63
7 changed files with 91 additions and 0 deletions
6
app-metrics/prometheus-cpu-mem-monitor/ChangeLog
Normal file
6
app-metrics/prometheus-cpu-mem-monitor/ChangeLog
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
*prometheus-cpu-mem-monitor-0.0.0.1 (11 Nov 2019)
|
||||||
|
|
||||||
|
11 Nov 2019; <manuel@gentoo.org> +files/prometheus-cpu-mem-monitor.service,
|
||||||
|
+files/prometheus-cpu-mem-monitor.sh, +files/prometheus-cpu-mem-monitor.timer,
|
||||||
|
+metadata.xml, +prometheus-cpu-mem-monitor-0.0.0.1.ebuild:
|
||||||
|
app-metrics/prometheus-cpu-mem-monitor: Add very first draft version
|
6
app-metrics/prometheus-cpu-mem-monitor/Manifest
Normal file
6
app-metrics/prometheus-cpu-mem-monitor/Manifest
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
AUX prometheus-cpu-mem-monitor.service 243 BLAKE2B 6f774e36b2e1b2dbc1614a930f2e64da9b664a0bef6023bb69db571949266625f32ec057ac31be12f1ec2fbcb9c5d7a732377471f750b5346384c366808ba42a SHA512 7d21c89a0ebf577fe654ef93b7098b4ef40127892213e26141583d64a8fadc683799b0da588b8ddb4a692129de536e3c75dc80be83939ba7a5c47f45e84be7b2
|
||||||
|
AUX prometheus-cpu-mem-monitor.sh 564 BLAKE2B 1fcff16c183709c569398795afbce2ab11e558badfb437b8e4048cde5102e7ae7fe58ea11f64cb1bce7754bdfd7f85bddcaaf4deefd2a658ca76b1973df9d8bc SHA512 dfbd52eb86dca8e0d576f262b98a4efe145524653a3cfe9ae51e14695d0a02d3fc7618e0f236b5200ef59b84d81acf373b3a49665dbc23c694f299a29569479e
|
||||||
|
AUX prometheus-cpu-mem-monitor.timer 291 BLAKE2B d41b99088752863c3ffaf065279702a5ddec90edabe0fd7ec11d71b883756f370c4236aa1c4074b4d3869b02f29142aca4b5247dd49281299d5625a3fe4f3509 SHA512 2245655fec3417c44c64c04074f1f5c061e7c80a3b34ba0f683c12b74b1a7c5c46abec16bb78fca479381982d8286bab0919be223c2e9c08d26d3e80ced772a3
|
||||||
|
EBUILD prometheus-cpu-mem-monitor-0.0.0.1.ebuild 470 BLAKE2B 804936dedf7f4ee79ae4094a409779ccbe2e7fbcd0e3411f3d20adb344313f7a48686d2f9258514abbb3f1a1e8af060fe67bc2ad5ccb92e5d254069ee7e20501 SHA512 37cbfca25bf066276284b379befb759b5f8f7bcb6bfd4b9c2653e561c12368ac9819a3a12ba00707631e5603b09bad358cf3ca2800359f3de7b0763b8ff3b54b
|
||||||
|
MISC ChangeLog 343 BLAKE2B 140091e8f77dcf9b15534d36836af7aac2981d7bf6dc7b042094fc992eb6da938df6dea003c5130568845953e8e74ec35d577b9e945128934e383ddb805c3b2b SHA512 c0a7b88771132f795a790b6bcf9586053fd539e0e48de20fb08030ea2e3dd22a6e1e2e640241403124bd16f9bfaf3617c7410df770c4ee697f73bca24cdef076
|
||||||
|
MISC metadata.xml 337 BLAKE2B bd72b6097fead5eaf80082790d3712ae0893b118140b62f58639f0e5c56bebf57dbd0ccd0ea19af82b2dce88c88c494d88290f98df4818e4fad3f4386398d171 SHA512 aee4825d8b90a8fd84fb558b9af4b7eb889fcf81bae6c7b317a9d69f62b06dd0f0bc2aa91aa2c32f10ff91fdbf64b341d7e5adc3c65a5225c7e0e92d7a6b7816
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Calculate host statistics for prometheus
|
||||||
|
# Written by Manuel Friedli
|
||||||
|
# Changelog:
|
||||||
|
# 2019-11-10: Inception
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Calculate CPU/Memory stats for prometheus
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/bin/prometheus-cpu-mem-monitor.sh
|
19
app-metrics/prometheus-cpu-mem-monitor/files/prometheus-cpu-mem-monitor.sh
Executable file
19
app-metrics/prometheus-cpu-mem-monitor/files/prometheus-cpu-mem-monitor.sh
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Extract per-process CPU and memory usage from "ps aux" and send the data to prometheus
|
||||||
|
#
|
||||||
|
|
||||||
|
TARGET_URL="http://localhost:9091/metrics/job/top/instance/vps-02.friedli.info"
|
||||||
|
|
||||||
|
z=$(ps aux)
|
||||||
|
|
||||||
|
while read -r z
|
||||||
|
do
|
||||||
|
cpustats=$cpustats$(awk '{print "cpu_usage{process=\""$11"\", pid=\""$2"\"}", $3z}');
|
||||||
|
memstats=$memstats$(awk '{print "memory_usage{process=\""$11"\", pid=\""$2"\"}", $4z}');
|
||||||
|
done <<< "$z"
|
||||||
|
|
||||||
|
curl -X POST -H "Content-Type: text/plain" --data "$cpustats
|
||||||
|
" ${TARGET_URL}
|
||||||
|
|
||||||
|
curl -X POST -H "Content-Type: text/plain" --data "$memstats
|
||||||
|
" ${TARGET_URL}
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Timer for calculating host statistics for prometheus
|
||||||
|
# Written by Manuel Friedli
|
||||||
|
# Changelog:
|
||||||
|
# 2019-11-10: Inception
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Timer for calculating CPU/Memory stats for prometheus
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=1s
|
||||||
|
OnUnitInactiveSec=10s
|
||||||
|
AccuracySec=1s
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
11
app-metrics/prometheus-cpu-mem-monitor/metadata.xml
Normal file
11
app-metrics/prometheus-cpu-mem-monitor/metadata.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
|
||||||
|
<pkgmetadata>
|
||||||
|
<maintainer type="person">
|
||||||
|
<email>manuel@fritteli.ch</email>
|
||||||
|
<name>Manuel Friedli</name>
|
||||||
|
</maintainer>
|
||||||
|
<upstream>
|
||||||
|
<remote-id type="github">prometheus/node_exporter</remote-id>
|
||||||
|
</upstream>
|
||||||
|
</pkgmetadata>
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Copyright 1999-2019 Gentoo Authors
|
||||||
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
|
EAPI=6
|
||||||
|
inherit user systemd
|
||||||
|
|
||||||
|
KEYWORDS="~amd64"
|
||||||
|
|
||||||
|
DESCRIPTION="CPU and memory monitoring for prometheus"
|
||||||
|
HOMEPAGE="https://gittr.ch/linux/gentoo-overlay"
|
||||||
|
LICENSE="GPL-2"
|
||||||
|
SLOT="0"
|
||||||
|
IUSE=""
|
||||||
|
|
||||||
|
DEPEND="sys-process/procps"
|
||||||
|
|
||||||
|
S="${WORKDIR}"
|
||||||
|
|
||||||
|
src_install() {
|
||||||
|
dobin "${FILESDIR}/${PN}.sh"
|
||||||
|
systemd_dounit "${FILESDIR}/${PN}.service"
|
||||||
|
systemd_dounit "${FILESDIR}/${PN}.timer"
|
||||||
|
}
|
Loading…
Reference in a new issue