aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgentlejo <josungil@gmail.com>2018-10-04 20:57:49 +0900
committerBen Kochie <superq@gmail.com>2018-10-04 13:57:49 +0200
commit2269df255c8627f819afd3d2d6bb99d809b2ac9c (patch)
tree878c5b4c67663ecf3fc3791222df142785ac4316 /examples
parent5da107b02c658d269886260710d1a0563154e49f (diff)
downloadprometheus_node_collector-2269df255c8627f819afd3d2d6bb99d809b2ac9c.tar.bz2
prometheus_node_collector-2269df255c8627f819afd3d2d6bb99d809b2ac9c.tar.xz
prometheus_node_collector-2269df255c8627f819afd3d2d6bb99d809b2ac9c.zip
Add node_exporter script for init.d (#1059)
* Add node_exporter script for init.d Signed-off-by: gentlejo <josungil@gmail.com>
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/init.d/node_exporter63
1 files changed, 63 insertions, 0 deletions
diff --git a/examples/init.d/node_exporter b/examples/init.d/node_exporter
new file mode 100755
index 0000000..74c6243
--- /dev/null
+++ b/examples/init.d/node_exporter
@@ -0,0 +1,63 @@
1#!/bin/bash
2
3RETVAL=0
4PROG="node_exporter"
5EXEC="/etc/node_exporter/node_exporter"
6LOCKFILE="/var/lock/subsys/$PROG"
7OPTIONS="-web.listen-address=:9201"
8
9# Source function library.
10if [ -f /etc/rc.d/init.d/functions ]; then
11 . /etc/rc.d/init.d/functions
12else
13 echo "/etc/rc.d/init.d/functions is not exists"
14 exit 0
15fi
16
17start() {
18 if [ -f $LOCKFILE ]
19 then
20 echo "$PROG is already running!"
21 else
22 echo -n "Starting $PROG: "
23 nohup $EXEC $OPTIONS >/dev/null 2>&1 &
24 RETVAL=$?
25 [ $RETVAL -eq 0 ] && touch $LOCKFILE && success || failure
26 echo
27 return $RETVAL
28 fi
29}
30
31stop() {
32 echo -n "Stopping $PROG: "
33 killproc $EXEC
34 RETVAL=$?
35 [ $RETVAL -eq 0 ] && rm -r $LOCKFILE && success || failure
36 echo
37}
38
39restart ()
40{
41 stop
42 sleep 1
43 start
44}
45
46case "$1" in
47 start)
48 start
49 ;;
50 stop)
51 stop
52 ;;
53 status)
54 status $PROG
55 ;;
56 restart)
57 restart
58 ;;
59 *)
60 echo "Usage: $0 {start|stop|restart|status}"
61 exit 1
62esac
63exit $RETVAL