From e856d50e5972a9964398b322fe4c4f57f354b481 Mon Sep 17 00:00:00 2001 From: Lasse Luttermann Poulsen Date: Thu, 17 Aug 2017 11:29:49 +0200 Subject: Minor structual fixes --- node-exporter/files/initd | 100 ++++++++++++++++++++++++++++++++++++ node-exporter/files/systemd.service | 12 +++++ node-exporter/install.sh | 4 -- node-exporter/node-exporter_init.d | 100 ------------------------------------ node-exporter/node-exporter_systemd | 15 ------ 5 files changed, 112 insertions(+), 119 deletions(-) create mode 100644 node-exporter/files/initd create mode 100644 node-exporter/files/systemd.service delete mode 100644 node-exporter/node-exporter_init.d delete mode 100644 node-exporter/node-exporter_systemd (limited to 'node-exporter') diff --git a/node-exporter/files/initd b/node-exporter/files/initd new file mode 100644 index 0000000..d482867 --- /dev/null +++ b/node-exporter/files/initd @@ -0,0 +1,100 @@ +#!/bin/bash +# +# +# +# Start on runlevels 3, 4 and 5. Start late, kill early. +# chkconfig: 345 95 05 +# +# +#!/bin/bash + +# absolute path to executable binary +progpath='##PROG##' + +# arguments to script +opts='##OPTS##' + +# binary program name +prog=$(basename $progpath) + +# pid file +pidfile="/var/run/${prog}.pid" + +# make sure full path to executable binary is found +! [ -x $progpath ] && echo "$progpath: executable not found" && exit 1 + +eval_cmd() { + local rc=$1 + if [ $rc -eq 0 ]; then + echo '[ OK ]' + else + echo '[FAILED]' + fi + return $rc +} + +start() { + # see if running + local pids=$(pgrep $prog) + + if [ -n "$pids" ]; then + echo "$prog (pid $pids) is already running" + return 0 + fi + printf "%-50s%s" "Starting $prog: " '' + $progpath $opts & + + # save pid to file if you want + echo $! > $pidfile + + # check again if running + pgrep $prog >/dev/null 2>&1 + eval_cmd $? +} + +stop() { + # see if running + local pids=$(pgrep $prog) + + if [ -z "$pids" ]; then + echo "$prog not running" + return 0 + fi + printf "%-50s%s" "Stopping $prog: " '' + rm -f $pidfile + kill -9 $pids + eval_cmd $? +} + +status() { + # see if running + local pids=$(pgrep $prog) + + if [ -n "$pids" ]; then + echo "$prog (pid $pids) is running" + else + echo "$prog is stopped" + fi +} + +case $1 in + start) + start + ;; + stop) + stop + ;; + status) + status + ;; + restart) + stop + sleep 1 + start + ;; + *) + echo "Usage: $0 {start|stop|status|restart}" + exit 1 +esac + +exit $? diff --git a/node-exporter/files/systemd.service b/node-exporter/files/systemd.service new file mode 100644 index 0000000..faa88b7 --- /dev/null +++ b/node-exporter/files/systemd.service @@ -0,0 +1,12 @@ +[Unit] +Description=node_exporter (Prometheus) +Documentation=https://prometheus.io/docs/introduction/overview/ +After=network-online.target + +[Service] +Restart=on-failure +ExecStart=##PROG## \ + ##OPTS## + +[Install] +WantedBy=multi-user.target diff --git a/node-exporter/install.sh b/node-exporter/install.sh index 9deb6e8..d342024 100644 --- a/node-exporter/install.sh +++ b/node-exporter/install.sh @@ -21,8 +21,4 @@ fi SCRIPT="`pwd`/$0" SCRIPT_PATH="`dirname $SCRIPT`" -echo "Script: $SCRIPT" -echo "Path: $SCRIPT_PATH" - - diff --git a/node-exporter/node-exporter_init.d b/node-exporter/node-exporter_init.d deleted file mode 100644 index 04a56f9..0000000 --- a/node-exporter/node-exporter_init.d +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# -# -# -# Start on runlevels 3, 4 and 5. Start late, kill early. -# chkconfig: 345 95 05 -# -# -#!/bin/bash - -# absolute path to executable binary -progpath='/usr/sbin/node_exporter' - -# arguments to script -opts='' - -# binary program name -prog=$(basename $progpath) - -# pid file -pidfile="/var/run/${prog}.pid" - -# make sure full path to executable binary is found -! [ -x $progpath ] && echo "$progpath: executable not found" && exit 1 - -eval_cmd() { - local rc=$1 - if [ $rc -eq 0 ]; then - echo '[ OK ]' - else - echo '[FAILED]' - fi - return $rc -} - -start() { - # see if running - local pids=$(pgrep $prog) - - if [ -n "$pids" ]; then - echo "$prog (pid $pids) is already running" - return 0 - fi - printf "%-50s%s" "Starting $prog: " '' - $progpath $opts & - - # save pid to file if you want - echo $! > $pidfile - - # check again if running - pgrep $prog >/dev/null 2>&1 - eval_cmd $? -} - -stop() { - # see if running - local pids=$(pgrep $prog) - - if [ -z "$pids" ]; then - echo "$prog not running" - return 0 - fi - printf "%-50s%s" "Stopping $prog: " '' - rm -f $pidfile - kill -9 $pids - eval_cmd $? -} - -status() { - # see if running - local pids=$(pgrep $prog) - - if [ -n "$pids" ]; then - echo "$prog (pid $pids) is running" - else - echo "$prog is stopped" - fi -} - -case $1 in - start) - start - ;; - stop) - stop - ;; - status) - status - ;; - restart) - stop - sleep 1 - start - ;; - *) - echo "Usage: $0 {start|stop|status|restart}" - exit 1 -esac - -exit $? \ No newline at end of file diff --git a/node-exporter/node-exporter_systemd b/node-exporter/node-exporter_systemd deleted file mode 100644 index 9dcd831..0000000 --- a/node-exporter/node-exporter_systemd +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Prometheus Server -Documentation=https://prometheus.io/docs/introduction/overview/ -After=network-online.target - -[Service] -User=prometheus -Group=prometheus -Restart=on-failure -ExecStart=/opt/prometheus/prometheus \ - --config.file=/etc/prometheus/prometheus.yml \ - --storage.tsdb.path=/var/lib/prometheus/data - -[Install] -WantedBy=multi-user.target -- cgit v1.1