Hide irrelevant error message 98/13598/6
authorTim Johnson <tijohnson@linuxfoundation.org>
Tue, 20 Nov 2018 03:13:17 +0000 (19:13 -0800)
committerTim Johnson <tijohnson@linuxfoundation.org>
Fri, 23 Nov 2018 14:50:39 +0000 (06:50 -0800)
Use 'systemctl' to get status of 'sysstat' on newer releases of Unbuntu
(16.04 & 18.04).  Keep 'grep' to get status of 'sysstat' on Ubuntu
14.4. Unexpected releases will now generate an error.

Change-Id: I9745373d38213838381d3f2f0b46a6358014b268
Signed-off-by: Tim Johnson <tijohnson@linuxfoundation.org>
shell/sysstat.sh

index 6ecab67..5b49625 100644 (file)
@@ -14,12 +14,25 @@ set +e  # DON'T fail build if script fails.
 OS=$(facter operatingsystem)
 case "$OS" in
     Ubuntu)
+        os_release=$(facter operatingsystemrelease)
+        case $os_release in
+            16.04|18.04)
+                if ! systemctl status sysstat > /dev/null; then
+                    exit 0
+                fi
+                ;;
+            14.04)
+                if [[ ! -f /etc/default/sysstat ]] ||
+                      ! grep --quiet 'ENABLED="true"' /etc/default/sysstat; then
+                    exit 0
+                fi
+                ;;
+            *)
+                echo "ERROR: Unknown Release: Ubuntu $os_release"
+                exit 1
+                ;;
+        esac
         SYSSTAT_PATH="/var/log/sysstat"
-
-        # Dont run the script when systat is not enabled by default
-        if ! grep --quiet 'ENABLED="true"' "/etc/default/sysstat"; then
-            exit 0
-        fi
     ;;
     CentOS|RedHat)
         SYSSTAT_PATH="/var/log/sa"