1 #!/bin/sh 2 # 3 # atop Startup script for the Atop process logging in background 4 # 5 # chkconfig: 2345 96 4 6 # description: Advanced system and process activity monitor 7 # 8 ### BEGIN INIT INFO 9 # Provides: atop 10 # Required-Start: $local_fs 11 # Required-Stop: $local_fs 12 # Default-Start: 2 3 4 5 13 # Default-Stop: 0 1 6 14 # Short-Description: Advanced system and process activity monitor 15 # Description: Advanced system and process activity monitor 16 ### END INIT INFO 17 18 # Check existance of binaries 19 [ -f /usr/bin/atop ] || exit 0 20 21 PIDFILE=/var/run/atop.pid 22 RETVAL=0 23 24 # See how we were called. 25 case "$1" in 26 start) 27 # Check if atop runs already 28 # 29 if [ -e $PIDFILE ] && ps -p `cat $PIDFILE` | grep 'atop$' > /dev/null 30 then 31 : 32 else 33 # Start atop 34 /usr/share/atop/atop.daily& 35 fi 36 touch /var/lock/subsys/atop 37 ;; 38 39 stop) 40 # Check if atop runs 41 # 42 if [ -e $PIDFILE ] && ps -p `cat $PIDFILE` | grep 'atop$' > /dev/null 43 then 44 kill -USR2 `cat $PIDFILE` # final sample and terminate 45 46 CNT=0 47 48 while ps -p `cat $PIDFILE` > /dev/null 49 do 50 CNT=$((CNT + 1)) 51 52 if [ $CNT -gt 5 ] 53 then 54 break; 55 fi 56 57 sleep 1 58 done 59 60 rm $PIDFILE 61 fi 62 rm -f /var/lock/subsys/atop 63 ;; 64 65 status) 66 ;; 67 68 reload) 69 /usr/share/atop/atop.daily& 70 ;; 71 72 restart) 73 /usr/share/atop/atop.daily& 74 ;; 75 76 *) 77 echo "Usage: $0 [start|stop|status|reload|restart]" 78 exit 1 79 esac 80 81 exit $RETVAL