-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrb_nr_agent
executable file
·78 lines (74 loc) · 1.8 KB
/
rb_nr_agent
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
#!/bin/bash
#
# copy this script to /etc/rc.d/init.d/rb_nr_agent
#
#
# chkconfig: 345 70 30
# description: NewRelic Agent Plugin for redborder platform
# processname: rb_nr_agent
#
RETVAL=0
prog="rb_nr_agent"
executable="newrelic_redborder_agent"
. /etc/init.d/functions
start() {
RESULT=`ps aux | grep $executable | grep -c -v grep`
if [ "${RESULT:-null}" -ge "1" ]; then
echo "$prog is currently running"
else
echo -n "Starting $prog: "
cd /opt/newrelic_rb_plugin/
#./newrelic_redborder_agent > /dev/null &
`/usr/local/rvm/bin/rvm ruby-2.1.2 do /opt/newrelic_rb_plugin/newrelic_redborder_agent > /dev/null &`
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo_success
else
echo_failure; failure
RETVAL=1
fi
echo
fi
return $RETVAL
}
stop() {
RESULT=`ps aux | grep $executable | grep -c -v grep`
if [ "${RESULT:-null}" -ge "1" ]; then
echo -n "Shutting down $prog: "
ps aux | grep $executable | grep -v grep | awk {'print $2'} | xargs kill -9 > /dev/null
else
echo "$executable is not running"
echo_failure; failure
fi
RETVAL=$?
[ $RETVAL -eq 0 ] && echo_success
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
RESULT=`ps aux | grep $executable | grep -c -v grep`
if [ "${RESULT:-null}" -ge "1" ]; then
echo "$executable is running"
RETVAL=1
else
echo "$executable is not running"
RETVAL=0
fi
;;
restart)
stop
start
;;
*)
echo "Usage: <servicename> {start|stop|status}"
exit 1
;;
esac
exit $?