|
|
1.1 root 1: #!/bin/sh -
2: #
3: # @(#)usermem.sh 5.4 (Berkeley) 9/17/85
4: #
5: : This shell script snoops around to find the maximum amount of available
6: : user memory. These variables need to be set only if there is no
7: : /usr/adm/messages. KMEM, UNIX, and CLICKSIZE can be set on the command
8: : line, if desired, e.g. UNIX=/unix
9: KMEM=/dev/kmem # User needs read access to KMEM
10: UNIX=
11: # VAX CLICKSIZE=512, UNIX=/vmunix
12: # PDP-11 CLICKSIZE=64, UNIX=/unix
13: # CADLINC 68000 CLICKSIZE=4096, UNIX=/unix
14: # Perkin-Elmer 3205 CLICKSIZE=4096, UNIX=/edition7
15: # Perkin-Elmer all others, CLICKSIZE=2048, UNIX=/edition7
16: CLICKSIZE=512
17: eval $*
18:
19: if test -n "$UNIX"
20: then
21: : User must have specified it already.
22: elif test -r /vmunix
23: then
24: UNIX=/vmunix
25: CLICKSIZE=512 # Probably VAX
26: elif test -r /edition7
27: then
28: UNIX=/edition7
29: CLICKSIZE=2048 # Perkin-Elmer: change to 4096 on a 3205
30: elif test -r /unix
31: then
32: UNIX=/unix # Could be anything
33: fi
34:
35: SIZE=0
36: # messages: probably the most transportable
37: if test -r /usr/adm/messages -a -s /usr/adm/messages
38: then
39: SIZE=`grep avail /usr/adm/messages | sed -n '$s/.*[ ]//p'`
40: fi
41:
42: if test 0$SIZE -le 0 # no SIZE in /usr/adm/messages
43: then
44: if test -r $KMEM # Readable KMEM
45: then
46: if test -n "$UNIX"
47: then
48: SIZE=`echo maxmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'`
49: if test 0$SIZE -le 0
50: then
51: SIZE=`echo physmem/D | adb $UNIX $KMEM | sed -n '$s/.*[ ]//p'`
52: fi
53: SIZE=`expr 0$SIZE '*' $CLICKSIZE`
54: fi
55: fi
56: fi
57:
58: case $UNIX in
59: /vmunix) # Assume 4.2bsd: check for resource limits
60: MAXSIZE=`csh -c limit | awk 'BEGIN { MAXSIZE = 1000000 }
61: /datasize|memoryuse/ && NF == 3 { if ($2 < MAXSIZE) MAXSIZE = $2 }
62: END { print MAXSIZE * 1000 }'`
63: if test $MAXSIZE -lt $SIZE
64: then
65: SIZE=$MAXSIZE
66: fi
67: ;;
68: esac
69:
70: if test 0$SIZE -le 0
71: then
72: echo 0;exit 1
73: else
74: echo $SIZE
75: fi
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.