forked from Atoptool/atop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatop.init
executable file
·72 lines (58 loc) · 1.01 KB
/
atop.init
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
#!/bin/sh
#
# atop This shell script takes care of initializing atop
#
# chkconfig: 2345 85 15
# description: Atop is a system and process activity monitor
#
# Check existance of binaries
[ -f /usr/bin/atop ] || exit 0
PIDFILE=/var/run/atop.pid
RETVAL=0
# See how we were called.
case "$1" in
start)
# Check if atop runs already
#
if [ -e $PIDFILE ] && ps -p `cat $PIDFILE` | grep 'atop$' > /dev/null
then
:
else
# Start atop
/etc/atop/atop.daily
fi
touch /var/lock/subsys/atop
;;
stop)
# Check if atop runs
#
if [ -e $PIDFILE ] && ps -p `cat $PIDFILE` | grep 'atop$' > /dev/null
then
kill -USR2 `cat $PIDFILE` # final sample and terminate
CNT=0
while ps -p `cat $PIDFILE` > /dev/null
do
let CNT+=1
if [ $CNT -gt 5 ]
then
break;
fi
sleep 1
done
rm $PIDFILE
fi
rm /var/lock/subsys/atop
;;
status)
;;
reload)
/etc/atop/atop.daily
;;
restart)
/etc/atop/atop.daily
;;
*)
echo "Usage: $0 [start|stop|status|reload|restart]"
exit 1
esac
exit $RETVAL