Browse Source

HPCC-17092 Report correct RAM values in CentOS 7

The preflight script uses 'free' command to retrieve system memory
values. The response format of the command is changed in CentOS 7.
This fix checks the format before retrieving the values from the
response.

Example of free on CentOS 7:
free
total used free shared buff/cache available
Mem: 24679696 745408 15354024 484056 8580264 23115424
Swap: 4194296 2342044 1852252

Example of free on other OS systems:
free
total used free shared buffers cached
Mem: 132186424 85905932 46280492 1269732 1246032 48452744
-/+ buffers/cache: 36207156 95979268
Swap: 8388600 1371044 7017556

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 8 years ago
parent
commit
e9d0a58dba
1 changed files with 6 additions and 1 deletions
  1. 6 1
      common/monitoring/preflight

+ 6 - 1
common/monitoring/preflight

@@ -63,7 +63,12 @@ if [ "${1:0:1}" == '-' ]; then
 
     #find machineInfo and output:
 
-    mem=`free | head -n 3 | tail -n 1 | awk '{print $3,$4}'`
+    checkSwapLine=`free | head -n 3 | tail -n 1 | awk '{print $1}'`
+    if ! [ "$checkSwapLine" = "Swap:" ]; then
+        mem=`free | head -n 3 | tail -n 1 | awk '{print $3,$4}'`
+    else
+        mem=`free | head -n 2 | tail -n 1 | awk '{print $2-$7,$7}'`
+    fi
     cpu=`vmstat 1 2 | tail -n 1 | awk '{print $15}'`
     echo CPU-Idle: $cpu%
     cuptime=`uptime | cut -f 1,2 -d ','`