File: pacct

package info (click to toggle)
acct 6.6.4-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,488 kB
  • sloc: ansic: 16,081; sh: 11,379; cpp: 290; makefile: 153
file content (59 lines) | stat: -rw-r--r-- 1,645 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
#
# Generate fake process accounting data via the package's installed
# service defitions and sanity check the output from lastcomm.

#set -x
set -e

FILE=/var/log/account/pacct

fail () { echo $1 >&2; exit 1; }

# Stop process accounting if it has already started
service acct stop >/dev/null 2>/dev/null || true
[ ! -s "$FILE" ] || truncate --size 0 "$FILE"

# Install test library
cp -a debian/tests/src $AUTOPKGTEST_TMP
cd $AUTOPKGTEST_TMP
make -C src
install -t /usr/local/bin src/gen-acct
install -t /usr/local/lib src/fake-acct.so
echo "/usr/local/lib/fake-acct.so" >> /etc/ld.so.preload

# Start fake process accounting
[ ! -s "$FILE" ] || fail "pacct already populated"
service acct start 2>&1
sleep 5
[ -f "$FILE" ] || fail "pacct did not get created"
sleep 20
service acct stop 2>&1
[ -s "$FILE" ] || fail "pacct did not grow"
sleep 5
sz=$(stat -c %b "$FILE")
sleep 10
[ "$sz" = $(stat -c %b "$FILE") ] || fail "psacct did not stop growing"

lastcomm > lastcomm.out 2> lastcomm.err
echo "First 5 lines of $(wc -l < lastcomm.out) from lastcomm:"
head -n5 lastcomm.out | cat -n
[ $(wc -l < lastcomm.out) -gt 10 ] || fail "lastcomm output too short"
if [ -s lastcomm.err ]
then
  echo "Error output from lastcomm:"
  cat lastcomm.err | cat -n
  exit 1
fi

cat lastcomm.out | cut -d\  -f1 > lastprocs
cat lastprocs | sort | uniq > a
ls /usr/bin > b1
ls /usr/sbin > b2
cat b1 b2 | cut -c1-16 | sort | uniq > b

echo "Some system binaries included in lastcomm output:"
comm -1 -2 a b | head -n5 | cat -n
common=$(comm -1 -2 -3 --total a b | cut -f3)

[ $common -gt 5 ] || fail "too few system binaries feature in lastcomm output"