diff options
author | Michael Boelen <michael.boelen@cisofy.com> | 2016-09-10 17:12:44 +0300 |
---|---|---|
committer | Michael Boelen <michael.boelen@cisofy.com> | 2016-09-10 17:12:44 +0300 |
commit | 903016df362e39444d314a81dd4a0ebc61b67da0 (patch) | |
tree | e922e2e0039428dec461bfea52ff8e503720370a /include/tests_memory_processes | |
parent | 2534fb99a9dbc869fd90f0967c6917191b306b69 (diff) |
Code cleanups and generic enhancements
Diffstat (limited to 'include/tests_memory_processes')
-rw-r--r-- | include/tests_memory_processes | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/include/tests_memory_processes b/include/tests_memory_processes index c767ddd0..a46650b0 100644 --- a/include/tests_memory_processes +++ b/include/tests_memory_processes @@ -33,13 +33,13 @@ if [ -f /proc/meminfo ]; then LogText "Result: found /proc/meminfo" Display --indent 2 --text "- Checking /proc/meminfo" --result "${STATUS_FOUND}" --color GREEN - FIND=`${AWKBINARY} '/^MemTotal/ { print $2, $3 }' /proc/meminfo` - MEMORY_SIZE=`echo ${FIND} | ${AWKBINARY} '{ print $1 }'` - MEMORY_UNITS=`echo ${FIND} | ${AWKBINARY} '{ print $2 }'` + FIND=$(${AWKBINARY} '/^MemTotal/ { print $2, $3 }' /proc/meminfo) + MEMORY_SIZE=$(echo ${FIND} | ${AWKBINARY} '{ print $1 }') + MEMORY_UNITS=$(echo ${FIND} | ${AWKBINARY} '{ print $2 }') LogText "Result: Found ${MEMORY_SIZE} ${MEMORY_UNITS} memory" Report "memory_size=${MEMORY_SIZE}" Report "memory_units=${MEMORY_UNITS}" - else + else LogText "Result: /proc/meminfo file not found on this system" fi fi @@ -48,17 +48,18 @@ # # Test : PROC-3604 # Description : Query /proc/meminfo + # Notes : TODO - prtconf replacement Register --test-no PROC-3604 --os Solaris --weight L --network NO --category security --description "Query prtconf for memory details" if [ ${SKIPTEST} -eq 0 ]; then LogText "Test: Searching /usr/sbin/prtconf" if [ -x /usr/sbin/prtconf ]; then Display --indent 2 --text "- Querying prtconf for installed memory" --result "${STATUS_DONE}" --color GREEN - MEMORY_SIZE=`/usr/sbin/prtconf | ${GREPBINARY} "^Memory size:" | ${CUTBINARY} -d ' ' -f3` - MEMORY_UNITS=`/usr/sbin/prtconf | ${GREPBINARY} "^Memory size:" | ${CUTBINARY} -d ' ' -f4` + MEMORY_SIZE=$(/usr/sbin/prtconf | ${GREPBINARY} "^Memory size:" | ${CUTBINARY} -d ' ' -f3) + MEMORY_UNITS=$(/usr/sbin/prtconf | ${GREPBINARY} "^Memory size:" | ${CUTBINARY} -d ' ' -f4) LogText "Result: Found ${MEMORY_SIZE} ${MEMORY_UNITS} memory" Report "memory_size=${MEMORY_SIZE}" Report "memory_units=${MEMORY_UNITS}" - else + else Display --indent 2 --text "- Querying prtconf for installed memory" --result "${STATUS_SKIPPED}" --color WHITE LogText "Result: /usr/sbin/prtconf not found" fi @@ -73,14 +74,14 @@ Register --test-no PROC-3612 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check dead or zombie processes" if [ ${SKIPTEST} -eq 0 ]; then if [ "${OS}" = "AIX" ]; then - FIND=`${PSBINARY} -Ae -o pid,stat,comm | ${AWKBINARY} '{ if ($2 ~ /Z|X/) print $1 }' | xargs` - else - FIND=`${PSBINARY} x -o pid,stat,comm | ${AWKBINARY} '{ if ($2 ~ /Z|X/) print $1 }' | xargs` + FIND=$(${PSBINARY} -Ae -o pid,stat,comm | ${AWKBINARY} '{ if ($2 ~ /Z|X/) print $1 }' | ${XARGSBINARY}) + else + FIND=$(${PSBINARY} x -o pid,stat,comm | ${AWKBINARY} '{ if ($2 ~ /Z|X/) print $1 }' | ${XARGSBINARY}) fi - if [ "${FIND}" = "" ]; then + if [ -z "${FIND}" ]; then LogText "Result: no zombie processes found" Display --indent 2 --text "- Searching for dead/zombie processes" --result "${STATUS_OK}" --color GREEN - else + else LogText "Result: found one or more dead or zombie processes" LogText "Output: PIDs ${FIND}" Display --indent 2 --text "- Searching for dead/zombie processes" --result "${STATUS_WARNING}" --color RED @@ -97,14 +98,14 @@ Register --test-no PROC-3614 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check heavy IO waiting based processes" if [ ${SKIPTEST} -eq 0 ]; then if [ "${OS}" = "AIX" ]; then - FIND=`${PSBINARY} -Ae -o pid,stat,comm | ${AWKBINARY} '{ if ($2=="D") print $1 }' | xargs` - else - FIND=`${PSBINARY} x -o pid,stat,comm | ${AWKBINARY} '{ if ($2=="D") print $1 }' | xargs` + FIND=$(${PSBINARY} -Ae -o pid,stat,comm | ${AWKBINARY} '{ if ($2=="D") print $1 }' | ${XARGSBINARY}) + else + FIND=$(${PSBINARY} x -o pid,stat,comm | ${AWKBINARY} '{ if ($2=="D") print $1 }' | ${XARGSBINARY}) fi - if [ "${FIND}" = "" ]; then + if [ -z "${FIND}" ]; then LogText "Result: No processes were waiting for IO requests to be handled first" Display --indent 2 --text "- Searching for IO waiting processes" --result "${STATUS_OK}" --color GREEN - else + else LogText "Result: found one or more processes which were waiting to get IO requests handled first" LogText "More info: processes which show up with the status flag 'D' are often stuck, until a disk IO event finished. This can happen for example with network storage, where the connection or protocol settings are not logtext well configured." LogText "Output: PIDs ${FIND}" |