Report memory usage with sys-info 32/5132/3
authorAnil Belur <abelur@linuxfoundation.org>
Fri, 9 Jun 2017 03:42:51 +0000 (13:42 +1000)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Sat, 10 Jun 2017 06:40:15 +0000 (02:40 -0400)
Earlier this was getting printed in the end of the console logs
which got missed out while porting to lftools.

Change-Id: Id7e59ecdc017c15ebbe1d540fa36eef19ced9d38
Co-Authored-By: Thanh Ha <thanh.ha@linuxfoundation.org>
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
shell/deploy

index 9ec165b..fb826ea 100755 (executable)
@@ -192,12 +192,24 @@ deploy_logs() {
     # Print system info before collecting logs
     touch "_sys-info.log"
     {
-        echo -e "---> uname -a:\n $(uname -a) \n"
-        echo -e "---> lscpu:\n $(lscpu) \n"
-        echo -e "---> nproc:\n $(nproc) \n"
-        echo -e "---> df -h:\n $(df -h) \n"
-        echo -e "---> free -m:\n $(free -m) \n"
-        echo -e "---> ip addr:\n $(/sbin/ip addr) \n"
+        local sys_cmds
+        sys_cmds=(
+            "uname -a"
+            "lscpu"
+            "nproc"
+            "df -h"
+            "free -m"
+            "ip addr"
+            "sar -r"
+        )
+        for cmd in "${sys_cmds[@]}"; do
+            # If command exists then print output.
+            set -- $cmd
+            hash $1 2> /dev/null
+            if [ "$?" -eq "0" ]; then
+                echo -e "---> $cmd:\n $($cmd) \n"
+            fi
+        done
     } 2>&1 | tee -a "_sys-info.log"
 
     # Magic string used to trim console logs at the appropriate level during wget