Last active
July 5, 2018 12:22
-
-
Save ArsSirek/59f26add5fda4353fe6bd3cc69ea4547 to your computer and use it in GitHub Desktop.
node_exporter ubuntu local network install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the command-line arguments to pass to the server. | |
# | |
# @origin source url - https://gist.github.com/eloo/a06d7c70ff2a841b7bb98cd322b851b9 | |
# | |
ARGS='-web.listen-address=selfprivateip:9100 -collector.diskstats.ignored-devices="^(ram|loop|fd)\\d+$"' | |
# Prometheus-node-exporter supports the following options: | |
# -collector.diskstats.ignored-devices="^(ram|loop|fd|(h|s|v|xv)d[a-z])\\d+$": Regexp of devices to ignore for diskstats. | |
# -collector.filesystem.ignored-mount-points="^/(sys|proc|dev)($|/)": Regexp of mount points to ignore for filesystem collector. | |
# -collector.ipvs.procfs="/proc": procfs mountpoint. | |
# -collector.megacli.command="megacli": Command to run megacli. | |
# -collector.ntp.server="": NTP server to use for ntp collector. | |
# -collector.textfile.directory="": Directory to read text files with metrics from. | |
# -collectors.enabled="diskstats,filesystem,loadavg,meminfo,stat,textfile,time,netdev,netstat": Comma-separated list of collectors to use. | |
# -collectors.print=false: If true, print available collectors and exit. | |
# -debug.memprofile-file="": Write memory profile to this file upon receipt of SIGUSR1. | |
# -log.level=info: Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal, panic]. | |
# -web.listen-address=":9100": Address on which to expose metrics and web interface. | |
# -web.telemetry-path="/metrics": Path under which to expose metrics. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: Node exporter | |
# Required-Start: $local_fs $network $named $time $syslog | |
# Required-Stop: $local_fs $network $named $time $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Description: Node exporter for prometheus written in Go | |
### END INIT INFO | |
# | |
# @origin source url - https://gist.github.com/eloo/a06d7c70ff2a841b7bb98cd322b851b9 | |
# | |
DAEMON=/etc/systemd/system/node_exporter.service | |
NAME=node_exporter | |
USER=node_exporter | |
PIDFILE=/var/run/node_exporter/$NAME.pid | |
LOGFILE=/var/log/node_exporter/$NAME.log | |
ARGS="" | |
[ -r /etc/default/$NAME ] && . /etc/default/$NAME | |
do_start_prepare() | |
{ | |
mkdir -p `dirname $PIDFILE` || true | |
mkdir -p `dirname $LOGFILE` || true | |
chown -R $USER: `dirname $LOGFILE` | |
chown -R $USER: `dirname $PIDFILE` | |
} | |
do_start_cmd() | |
{ | |
do_start_prepare | |
echo -n "Starting daemon: "$NAME | |
start-stop-daemon --chuid $USER -C --background --start --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- $ARGS >> $LOGFILE 2>&1 | |
echo "." | |
} | |
do_stop_cmd() | |
{ | |
echo -n "Stopping daemon: "$NAME | |
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE | |
rm $PIDFILE | |
echo "." | |
} | |
uninstall() { | |
echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] " | |
local SURE | |
read SURE | |
if [ "$SURE" = "yes" ]; then | |
stop | |
rm -f "$PIDFILE" | |
echo "Notice: log file was not removed: '$LOGFILE'" >&2 | |
update-rc.d -f <NAME> remove | |
rm -fv "$0" | |
fi | |
} | |
status() { | |
printf "%-50s" "Checking $NAME..." | |
if [ -f $PIDFILE ]; then | |
PID=$(cat $PIDFILE) | |
if [ -z "$(ps axf | grep ${PID} | grep -v grep)" ]; then | |
printf "%s\n" "The process appears to be dead but pidfile still exists" | |
else | |
echo "Running, the PID is $PID" | |
fi | |
else | |
printf "%s\n" "Service not running" | |
fi | |
} | |
case "$1" in | |
start) | |
do_start_cmd | |
;; | |
stop) | |
do_stop_cmd | |
;; | |
status) | |
status | |
;; | |
uninstall) | |
uninstall | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $1 {start|stop|status|restart|uninstall}" | |
exit 1 | |
esac | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Node Exporter | |
Wants=network-online.target | |
After=network-online.target | |
[Service] | |
User=node_exporter | |
Group=node_exporter | |
Type=simple | |
ExecStart=/usr/local/bin/node_exporter --web.listen-address="selfprivateip:9100" | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
die () { | |
echo >&2 "$@" | |
exit 1 | |
} | |
[ "$#" -eq 1 ] || die "1 argument required (your local network ip to publish metrics on), $# provided" | |
useradd --no-create-home --shell /bin/false node_exporter | |
cd ~ | |
curl -LO https://github.com/prometheus/node_exporter/releases/download/v0.16.0/node_exporter-0.16.0.linux-amd64.tar.gz | |
tar xvf node_exporter-* | |
mv node_exporter-*/node_exporter /usr/local/bin | |
chown node_exporter:node_exporter /usr/local/bin/node_exporter | |
rm -rf node_exporter-* | |
ln -s /usr/local/bin/node_exporter /usr/bin/node_exporter | |
echo "$1 selfprivateip" >> /etc/hosts | |
curl -LO https://gist.githubusercontent.com/ArsSirek/59f26add5fda4353fe6bd3cc69ea4547/raw/init.d | |
mv init.d /etc/init.d/node_exporter | |
chmod +x /etc/init.d/node_exporter | |
curl -LO https://gist.githubusercontent.com/ArsSirek/59f26add5fda4353fe6bd3cc69ea4547/raw/node_exporter.service | |
mv node_exporter.service /etc/systemd/system/node_exporter.service | |
curl -LO https://gist.githubusercontent.com/ArsSirek/59f26add5fda4353fe6bd3cc69ea4547/raw/defaults | |
mv defaults /etc/default/node_exporter | |
update-rc.d node_exporter defaults |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment