diff options
author | gentlejo <josungil@gmail.com> | 2018-10-04 20:57:49 +0900 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2018-10-04 13:57:49 +0200 |
commit | 2269df255c8627f819afd3d2d6bb99d809b2ac9c (patch) | |
tree | 878c5b4c67663ecf3fc3791222df142785ac4316 /examples | |
parent | 5da107b02c658d269886260710d1a0563154e49f (diff) | |
download | prometheus_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-x | examples/init.d/node_exporter | 63 |
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 | |||
3 | RETVAL=0 | ||
4 | PROG="node_exporter" | ||
5 | EXEC="/etc/node_exporter/node_exporter" | ||
6 | LOCKFILE="/var/lock/subsys/$PROG" | ||
7 | OPTIONS="-web.listen-address=:9201" | ||
8 | |||
9 | # Source function library. | ||
10 | if [ -f /etc/rc.d/init.d/functions ]; then | ||
11 | . /etc/rc.d/init.d/functions | ||
12 | else | ||
13 | echo "/etc/rc.d/init.d/functions is not exists" | ||
14 | exit 0 | ||
15 | fi | ||
16 | |||
17 | start() { | ||
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 | |||
31 | stop() { | ||
32 | echo -n "Stopping $PROG: " | ||
33 | killproc $EXEC | ||
34 | RETVAL=$? | ||
35 | [ $RETVAL -eq 0 ] && rm -r $LOCKFILE && success || failure | ||
36 | echo | ||
37 | } | ||
38 | |||
39 | restart () | ||
40 | { | ||
41 | stop | ||
42 | sleep 1 | ||
43 | start | ||
44 | } | ||
45 | |||
46 | case "$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 | ||
62 | esac | ||
63 | exit $RETVAL | ||