forked from jkstill/memory-verify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregex-test.sh
executable file
·55 lines (39 loc) · 1.81 KB
/
regex-test.sh
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
#!/usr/bin/bash
# test regex for pulling memlock from /etc/security/limits.conf
# duplicate entries may appear in the file
# the following are duplicates for 'oracle soft memlock'
# the second one of 1078768 will be the one used by the system
#
# oracle soft memlock 5078768
# oracle soft memlock 1078768
# Test Variables
TOTALMEM=33554432
(( TOTALMEM_BYTES = TOTALMEM * 1024 ))
LIMITS_FILE=limits-test.conf
#######################################
# from the limits.conf man page
# All items support the values -1, unlimited or infinity indicating no limit, except for priority and nice.
UNLIMITED_REGEX='unlimited|infinity|-1'
SOFT_MEMLOCK=$( grep -E "^oracle.*soft.*memlock.*($UNLIMITED_REGEX)|^oracle.*soft.*memlock.*[0-9]++" $LIMITS_FILE | tail -1 | awk '{ print $4 }')
if [[ -z $SOFT_MEMLOCK ]]; then
SOFT_MEMLOCK=$( grep -E "^\*.*soft.*memlock.*($UNLIMITED_REGEX)|^\*.*soft.*memlock.*[0-9]+" $LIMITS_FILE | tail -1 | awk '{ print $4 }')
fi
[[ $(echo $SOFT_MEMLOCK | grep -E "$UNLIMITED_REGEX") ]] && SOFT_MEMLOCK=$TOTALMEM
HARD_MEMLOCK=$( grep -E "^oracle.*hard.*memlock.*($UNLIMITED_REGEX)|^oracle.*hard.*memlock.*[0-9]+" $LIMITS_FILE | tail -1 | awk '{ print $4 }')
if [[ -z $HARD_MEMLOCK ]]; then
HARD_MEMLOCK=$( grep -E "^\*.*hard.*memlock.*($UNLIMITED_REGEX)|^\*.*hard.*memlock.*[0-9]+" $LIMITS_FILE | tail -1 | awk '{ print $4 }')
fi
[[ $(echo $HARD_MEMLOCK | grep -E "$UNLIMITED_REGEX") ]] && HARD_MEMLOCK=$TOTALMEM
[[ -z $SOFT_MEMLOCK ]] && SOFT_MEMLOCK=0
[[ -z $HARD_MEMLOCK ]] && HARD_MEMLOCK=0
(( SOFT_MEMLOCK_BYTES = SOFT_MEMLOCK * 1024 ))
(( HARD_MEMLOCK_BYTES = HARD_MEMLOCK * 1024 ))
cat <<MEMINFO
OS:
totalmem: $TOTALMEM
in bytes: $TOTALMEM_BYTES
soft_memlock: $SOFT_MEMLOCK
in bytes: $SOFT_MEMLOCK_BYTES
hard_memlock: $HARD_MEMLOCK
in bytes: $HARD_MEMLOCK_BYTES
MEMINFO