-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathamon-agent
executable file
·72 lines (54 loc) · 1.44 KB
/
amon-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
#!/usr/bin/env sh
# chkconfig: 2345 95 05
# description: Amon agent - collects system and process information.
# processname: amon-agent
# pidfile: /var/run/amonagent/amonagent.pid
### BEGIN INIT INFO
# Provides: amon-agent
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the Amon agent
# Description: Amon agent - collects system and process information.
### END INIT INFO
AGENTPATH='/usr/bin/amon-agent.py'
AGENTUSER="amonagent"
PIDPATH="/var/run/amonagent/"
[ -f $AGENTPATH ] || echo "$AGENTPATH not found"
. /etc/rc.d/init.d/functions
action=$1
case $action in
start)
if [ ! -d $PIDPATH ]; then
mkdir -p $PIDPATH
chown amonagent:amonagent $PIDPATH
fi
su $AGENTUSER -c "python $AGENTPATH stop"
su $AGENTUSER -c "python $AGENTPATH start"
;;
stop)
su $AGENTUSER -c "python $AGENTPATH stop"
exit $?
;;
restart)
$0 stop
$0 start
exit $?
;;
status)
su $AGENTUSER -c "python $AGENTPATH status"
exit $?
;;
install)
su -c "python $AGENTPATH install $2"
exit $?
;;
test)
su $AGENTUSER -c "python $AGENTPATH test"
;;
*)
echo "Usage: $0 {start|stop|restart|status|test}"
exit 2
;;
esac