"Fossies" - the Fresh Open Source Software Archive

Member "atop-2.8.1/atopacct.init" (7 Jan 2023, 1739 Bytes) of package /linux/misc/atop-2.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "atopacct.init": 2.6.0_vs_2.7.0.

    1 #!/bin/sh
    2 #
    3 # atopacctd Startup script for the atopacctd daemon 
    4 #
    5 # chkconfig: 2345 91 9
    6 # description: Process accounting control
    7 #
    8 ### BEGIN INIT INFO
    9 # Provides:             atopacct
   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: This daemon switches on process accounting and
   15 #                    transfers the process accounting records 'realtime'
   16 #                    to small shadow files to avoid huge disk space usage
   17 # Description: Process accounting control
   18 ### END INIT INFO
   19 
   20 # Check existance of binaries 
   21 [ -f /usr/sbin/atopacctd ] || exit 0
   22 
   23 RETVAL=0
   24 
   25 # See how we were called.
   26 case "$1" in
   27   start)
   28     # Check if process accounting already in use via separate psacct package
   29     #
   30     for PACCTFILE in /var/account/pacct /var/log/pacct /var/log/account/pacct
   31     do
   32         if [ -f "$PACCTFILE" ]  # file exists?
   33         then
   34             BEFORSIZE=$(ls -lL "$PACCTFILE" | awk '{print $5}')
   35             AFTERSIZE=$(ls -lL "$PACCTFILE" | awk '{print $5}')
   36 
   37             # verify if accounting file grows, so is in use
   38             #
   39             if [ $BEFORSIZE -lt $AFTERSIZE ]
   40             then
   41                echo Process accounting already used by psacct! >&2
   42                exit $RETVAL     # do not start atopacctd
   43             fi
   44         fi
   45     done
   46 
   47 
   48     # Check if atopacctd runs already
   49     #
   50     if ps -e | grep -q atopacctd$
   51     then
   52         :
   53     else
   54         # Start atopacctd
   55         rm -rf /var/run/pacct_shadow.d 2> /dev/null
   56         /usr/sbin/atopacctd
   57     fi
   58 
   59     touch /var/lock/subsys/atopacctd
   60     ;;
   61 
   62   stop)
   63     # Check if atopacctd runs
   64     #
   65     if ps -e | grep -q atopacctd$
   66     then
   67         kill $(ps -e | grep atopacctd$ | sed 's/^ *//' | cut -d' ' -f1)
   68     fi
   69     rm -f /var/lock/subsys/atopacctd
   70     ;;
   71 
   72   status)
   73     ;;
   74 
   75   reload)
   76     ;;
   77 
   78   restart)
   79     ;;
   80 
   81   *)
   82     echo "Usage: $0 [start|stop]"
   83     exit 1
   84 esac
   85 
   86 exit $RETVAL