-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkibana
97 lines (83 loc) · 2.37 KB
/
kibana
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Kibana 4"
NAME=kibana
DAEMON=/opt/kibana/bin/kibana
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
LOG=/var/log/kibana.log
pid_file_exists() {
[ -f "$PIDFILE" ]
}
do_start() {
if pid_file_exists
then
echo "Kibana is already running"
else
$DAEMON $DAEMON_ARGS 1>"$LOG" 2>&1 &
echo $! > "$PIDFILE"
PID=$!
if [ "$PID" -ne "0" ]
then
echo "Kibana started with pid $!"
else
echo "Kibana could not be started"
fi
fi
}
do_status() {
if pid_file_exists
then
PID=$(cat $PIDFILE)
STATUS=$(ps ax | grep $PID | grep -v grep | awk '{print $1}')
if [ "$STATUS" == "$PID" ]
then
echo "Kibana is running on proccess $PID"
else
echo "Kibana is NOT running"
rm $PIDFILE
fi
else
echo "Kibana is NOT running"
fi
}
do_stop() {
if pid_file_exists
then
PID=$(cat $PIDFILE)
STATUS=$(ps ax | grep $PID | grep -v grep | awk '{print $1}')
if [ "$STATUS" == "$PID" ]
then
echo "Killing Kibana...."
KILL=$(kill -15 $PID)
rm $PIDFILE
sleep 1
echo -e "\tKibana (PID:$PID) killed"
else
echo "Kibana is NOT running"
rm $PIDFILE
fi
else
echo "Kibana is NOT running"
fi
}
case "$1" in
start)
do_start;;
stop)
do_stop
;;
status)
do_status
;;
restart)
do_stop
do_start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
exit 3
;;
esac
: