mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-16 19:50:19 +01:00
network/node_exporter: Added (Exporter for machine metrics).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
parent
99f0ec3026
commit
330a2c33d5
7 changed files with 308 additions and 0 deletions
25
network/node_exporter/README
Normal file
25
network/node_exporter/README
Normal file
|
@ -0,0 +1,25 @@
|
|||
Node exporter is a Go program that collects and exports metrics from
|
||||
*NIX kernels to Prometheus. It supports various collectors for CPU,
|
||||
disk, network, filesystem, and more.
|
||||
|
||||
To have the node_exporter daemon start with your host,
|
||||
add to /etc/rc.d/rc.local:
|
||||
|
||||
if [ -x /etc/rc.d/rc.node_exporter ]; then
|
||||
/etc/rc.d/rc.node_exporter start
|
||||
fi
|
||||
|
||||
To enable TLS, create file /etc/node_exporter/web.yml containing:
|
||||
|
||||
tls_server_config:
|
||||
cert_file: /etc/node_exporter/node_exporter.crt
|
||||
key_file: /etc/node_exporter/node_exporter.key
|
||||
|
||||
and place key and cert to the same directory.
|
||||
In /etc/default/node_exporter modify NODE_EXPORTER_ARGS to:
|
||||
|
||||
NODE_EXPORTER_ARGS="--web.config.file=/etc/node_exporter/web.yml"
|
||||
|
||||
|
||||
NOTE: google-go-lang is only needed at compile time - not needed for
|
||||
runtime.
|
5
network/node_exporter/config/node_exporter.default
Normal file
5
network/node_exporter/config/node_exporter.default
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Set the command-line arguments to pass to the server.
|
||||
NODE_EXPORTER_ARGS=""
|
||||
|
||||
# Run as specific user (default nobody)
|
||||
#NODE_EXPORTER_USER=nobody
|
131
network/node_exporter/config/rc.node_exporter
Normal file
131
network/node_exporter/config/rc.node_exporter
Normal file
|
@ -0,0 +1,131 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Node Exporter startup script for Slackware Linux
|
||||
#
|
||||
|
||||
BASE=node_exporter
|
||||
SERVER=/usr/bin/${BASE}
|
||||
|
||||
# Default options.
|
||||
if [ -f /etc/default/node_exporter ]; then
|
||||
. /etc/default/node_exporter
|
||||
fi
|
||||
|
||||
NODE_EXPORTER_USER=${NODE_EXPORTER_USER:=nobody}
|
||||
NODE_EXPORTER_ARGS=${NODE_EXPORTER_ARGS:=""}
|
||||
NODE_EXPORTER_LOG_FACILITY=${NODE_EXPORTER_LOG_FACILITY:=daemon.info}
|
||||
NODE_EXPORTER_PID=/var/run/node_exporter/node_exporter.pid
|
||||
|
||||
# Check if server is present.
|
||||
if [ ! -x ${SERVER} ]; then
|
||||
echo "${SERVER} not present or not executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if daemon is present.
|
||||
if [ ! -x /usr/bin/daemon ]; then
|
||||
echo "/usr/bin/daemon not present or not executable"
|
||||
echo "> slackpkg install daemon"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wait_for_pid () {
|
||||
try=0
|
||||
|
||||
while test $try -lt 5 ; do
|
||||
case "$1" in
|
||||
'created')
|
||||
if [ -f "$2" ] ; then
|
||||
try=''
|
||||
break
|
||||
fi
|
||||
;;
|
||||
|
||||
'removed')
|
||||
if [ ! -f "$2" ] ; then
|
||||
try=''
|
||||
break
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -n .
|
||||
try=`expr $try + 1`
|
||||
sleep 1
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
node_exporter_start() {
|
||||
if [ -f $NODE_EXPORTER_PID ]; then
|
||||
echo "$NODE_EXPORTER_PID file exists, $BASE is probably running"
|
||||
exit 0
|
||||
else
|
||||
echo -n "Starting ${BASE} ..."
|
||||
daemon --user=$NODE_EXPORTER_USER \
|
||||
--pidfile=$NODE_EXPORTER_PID \
|
||||
--output=$NODE_EXPORTER_LOG_FACILITY -- \
|
||||
$SERVER $NODE_EXPORTER_ARGS
|
||||
|
||||
wait_for_pid created $NODE_EXPORTER_PID
|
||||
|
||||
if [ -n "$try" ] ; then
|
||||
echo " failed"
|
||||
exit 1
|
||||
else
|
||||
echo " done"
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
node_exporter_stop() {
|
||||
echo -n "Stopping ${BASE} ..."
|
||||
if [ -f $NODE_EXPORTER_PID ]; then
|
||||
kill $(cat $NODE_EXPORTER_PID)
|
||||
|
||||
wait_for_pid removed $NODE_EXPORTER_PID
|
||||
|
||||
if [ -n "$try" ] ; then
|
||||
echo " failed"
|
||||
exit 1
|
||||
else
|
||||
echo " done"
|
||||
fi
|
||||
else
|
||||
echo "not running"
|
||||
fi
|
||||
}
|
||||
|
||||
node_exporter_restart() {
|
||||
node_exporter_stop
|
||||
node_exporter_start
|
||||
}
|
||||
|
||||
node_exporter_status() {
|
||||
if [ -f $NODE_EXPORTER_PID ]; then
|
||||
echo "Status of ${BASE}: running"
|
||||
else
|
||||
echo "Status of ${BASE}: stopped"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
node_exporter_start
|
||||
;;
|
||||
'stop')
|
||||
node_exporter_stop
|
||||
;;
|
||||
'restart')
|
||||
node_exporter_restart
|
||||
;;
|
||||
'status')
|
||||
node_exporter_status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
esac
|
||||
|
||||
exit 0
|
26
network/node_exporter/doinst.sh
Normal file
26
network/node_exporter/doinst.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
config() {
|
||||
NEW="$1"
|
||||
OLD="$(dirname $NEW)/$(basename $NEW .new)"
|
||||
# If there's no config file by that name, mv it over:
|
||||
if [ ! -r $OLD ]; then
|
||||
mv $NEW $OLD
|
||||
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
|
||||
# toss the redundant copy
|
||||
rm $NEW
|
||||
fi
|
||||
# Otherwise, we leave the .new copy for the admin to consider...
|
||||
}
|
||||
|
||||
preserve_perms() {
|
||||
NEW="$1"
|
||||
OLD="$(dirname $NEW)/$(basename $NEW .new)"
|
||||
if [ -e $OLD ]; then
|
||||
cp -a $OLD ${NEW}.incoming
|
||||
cat $NEW > ${NEW}.incoming
|
||||
mv ${NEW}.incoming $NEW
|
||||
fi
|
||||
config $NEW
|
||||
}
|
||||
|
||||
preserve_perms etc/rc.d/rc.node_exporter.new
|
||||
config etc/default/node_exporter.new
|
92
network/node_exporter/node_exporter.SlackBuild
Normal file
92
network/node_exporter/node_exporter.SlackBuild
Normal file
|
@ -0,0 +1,92 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Slackware build script for node_exporter
|
||||
|
||||
# Copyright 2024 Petr Valenta <petr@jevklidu.cz>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use of this script, with or without modification, is
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of this script must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
cd $(dirname $0) ; CWD=$(pwd)
|
||||
|
||||
PRGNAM=node_exporter
|
||||
VERSION=${VERSION:-1.8.2}
|
||||
GITHASH=${GITHASH:-f1e0e8360aa60b6cb5e5cc1560bed348fc2c1895}
|
||||
BUILD=${BUILD:-1}
|
||||
TAG=${TAG:-_SBo}
|
||||
PKGTYPE=${PKGTYPE:-tgz}
|
||||
|
||||
SRCNAM=node_exporter
|
||||
|
||||
if [ -z "$ARCH" ]; then
|
||||
case "$( uname -m )" in
|
||||
i?86) ARCH=i586 ;;
|
||||
arm*) ARCH=arm ;;
|
||||
*) ARCH=$( uname -m ) ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
|
||||
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TMP=${TMP:-/tmp/SBo}
|
||||
PKG=$TMP/package-$PRGNAM
|
||||
OUTPUT=${OUTPUT:-/tmp}
|
||||
|
||||
set -e
|
||||
|
||||
rm -rf $PKG
|
||||
mkdir -p $TMP $PKG $OUTPUT
|
||||
cd $TMP
|
||||
rm -rf $SRCNAM-$VERSION
|
||||
tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
|
||||
cd $SRCNAM-$VERSION
|
||||
chown -R root:root .
|
||||
find -L . \
|
||||
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
|
||||
-o -perm 511 \) -exec chmod 755 {} \+ -o \
|
||||
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
|
||||
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+
|
||||
|
||||
mkdir build
|
||||
|
||||
GO111MODULE=auto GOPATH=$TMP/$SRCNAM-$VERSION/build go build
|
||||
|
||||
install -D -m 0755 -s node_exporter $PKG/usr/bin/node_exporter
|
||||
install -D -m 0644 $CWD/config/node_exporter.default $PKG/etc/default/node_exporter.new
|
||||
install -D -m 0644 $CWD/config/rc.node_exporter $PKG/etc/rc.d/rc.node_exporter.new
|
||||
|
||||
mkdir -p $PKG/var/run/node_exporter
|
||||
chown nobody $PKG/var/run/node_exporter
|
||||
|
||||
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
|
||||
cp -a LICENSE NOTICE README.md $PKG/usr/doc/$PRGNAM-$VERSION
|
||||
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
|
||||
cat $CWD/README > $PKG/usr/doc/$PRGNAM-$VERSION/README.Slackware
|
||||
|
||||
mkdir -p $PKG/install
|
||||
cat $CWD/slack-desc > $PKG/install/slack-desc
|
||||
cat $CWD/doinst.sh > $PKG/install/doinst.sh
|
||||
|
||||
|
||||
cd $PKG
|
||||
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
|
||||
|
10
network/node_exporter/node_exporter.info
Normal file
10
network/node_exporter/node_exporter.info
Normal file
|
@ -0,0 +1,10 @@
|
|||
PRGNAM="node_exporter"
|
||||
VERSION="1.8.2"
|
||||
HOMEPAGE="https://github.com/prometheus/node_exporter"
|
||||
DOWNLOAD="https://github.com/prometheus/node_exporter/archive/v1.8.2/node_exporter-1.8.2.tar.gz"
|
||||
MD5SUM="096bfaf7a902b105288b616cc3215d63"
|
||||
DOWNLOAD_x86_64=""
|
||||
MD5SUM_x86_64=""
|
||||
REQUIRES="google-go-lang"
|
||||
MAINTAINER="Petr Valenta"
|
||||
EMAIL="petr@jevklidu.cz"
|
19
network/node_exporter/slack-desc
Normal file
19
network/node_exporter/slack-desc
Normal file
|
@ -0,0 +1,19 @@
|
|||
# HOW TO EDIT THIS FILE:
|
||||
# The "handy ruler" below makes it easier to edit a package description.
|
||||
# Line up the first '|' above the ':' following the base package name, and
|
||||
# the '|' on the right side marks the last column you can put a character in.
|
||||
# You must make exactly 11 lines for the formatting to be correct. It's also
|
||||
# customary to leave one space after the ':' except on otherwise blank lines.
|
||||
|
||||
|-----handy-ruler------------------------------------------------------|
|
||||
node_exporter: node_exporter (metrics for Prometheus)
|
||||
node_exporter:
|
||||
node_exporter: Prometheus exporter for hardware and OS metrics exposed by
|
||||
node_exporter: *NIX kernels, written in Go with pluggable metric collectors.
|
||||
node_exporter:
|
||||
node_exporter: Homepage: https://github.com/prometheus/node_exporter
|
||||
node_exporter: Guide: https://prometheus.io/docs/guides/node-exporter/
|
||||
node_exporter:
|
||||
node_exporter:
|
||||
node_exporter:
|
||||
node_exporter:
|
Loading…
Reference in a new issue