File: atopacct.rc.openrc

package info (click to toggle)
atop 2.8.1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,112 kB
  • sloc: ansic: 27,274; python: 253; sh: 231; makefile: 170
file content (39 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download | duplicates (2)
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
#!/sbin/openrc-run
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

description="Resource-specific view of processes"
command="/usr/sbin/atopacctd"
lockfile="/var/lock/subsys/atopacctd"

start_pre() {
	# Check if process accounting already in use via psacct
        for PACCTFILE in /var/account/pacct /var/log/pacct ; do
                if [ -f "${PACCTFILE}" ] ; then
                        BEFORSIZE=$(stat -c %s "${PACCTFILE}")
                        AFTERSIZE=$(stat -c %s "${PACCTFILE}")

                        # verify if accounting file grows, so is in use
                        if [ ${BEFORSIZE} -lt ${AFTERSIZE} ] ; then
				ewarn "Process accounting already used by psacct!"
				return 1
			fi
		fi
	done

	checkpath -d -q ${lockfile%/*} || return 1
}

start() {
	ebegin "Starting atopacctd"
	start-stop-daemon --start --exec ${command}
	touch ${lockfile}
	eend $?
}

stop() {
	ebegin "Stopping atopacctd"
	start-stop-daemon --stop --exec ${command}
	rm ${lockfile}
	eend $?
}