2020-04-25 17:18:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ "$EUID" -ne 0 ]
|
|
|
|
then echo "Please run as root"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
|
|
|
|
|
|
|
if getent passwd node_exporter > /dev/null 2>&1; then
|
|
|
|
echo "User already exists!"
|
|
|
|
else
|
|
|
|
adduser --system --no-create-home --group --shell=/bin/false node_exporter
|
|
|
|
fi
|
|
|
|
|
|
|
|
if service --status-all | grep -Fq 'node_exporter'; then
|
|
|
|
service node_exporter stop
|
|
|
|
fi
|
|
|
|
|
2020-04-25 17:23:55 +00:00
|
|
|
echo "Copying exporter"
|
|
|
|
|
2020-04-25 17:22:46 +00:00
|
|
|
mkdir -p /usr/prometheus
|
|
|
|
|
2020-04-25 17:23:55 +00:00
|
|
|
echo "Checking/Creating systemd configuration"
|
|
|
|
|
2020-04-25 17:21:34 +00:00
|
|
|
cp $SCRIPTPATH/node_exporter /usr/prometheus/node_exporter
|
2020-04-25 17:18:49 +00:00
|
|
|
chmod +x /usr/prometheus/node_exporter
|
|
|
|
|
|
|
|
cp $SCRIPTPATH/node_exporter.service /etc/systemd/system/
|
|
|
|
|
|
|
|
[ ! -d /etc/sysconfig ] && mkdir /etc/sysconfig
|
|
|
|
|
|
|
|
if [ -f "/etc/sysconfig/node_exporter" ]; then
|
|
|
|
echo "/etc/sysconfig/node_exporter already there. Skipping."
|
|
|
|
else
|
|
|
|
cp $SCRIPTPATH/node_exporter.sysconfig /etc/sysconfig/node_exporter
|
|
|
|
fi
|
|
|
|
|
2020-04-25 17:23:55 +00:00
|
|
|
echo "Starting Exporter"
|
|
|
|
|
2020-04-25 17:18:49 +00:00
|
|
|
systemctl enable node_exporter.service
|
2020-04-25 17:21:34 +00:00
|
|
|
service node_exporter start
|