Pārlūkot izejas kodu

Updated debug-output definitions, bumped version to 1.3

Michael Honkoop 1 nedēļu atpakaļ
vecāks
revīzija
e65079fce9
1 mainītis faili ar 38 papildinājumiem un 37 dzēšanām
  1. 38 37
      localchecks/groupwise.sh

+ 38 - 37
localchecks/groupwise.sh

@@ -10,9 +10,11 @@
 # - Aligned quotation marks around variables cosistently
 # v1.2:
 # - started refining the script to a more modern bash-style
+# v1.3:
+# - adapted debug-output
 #
 # Current active version of the script
-SCRIPT_VERSION=1.2
+SCRIPT_VERSION=1.3
 
 ################################################################
 # Global definitions for the script - change to fit your needs #
@@ -37,87 +39,87 @@ SERVICE="GroupWise"
 # DO NOT CHANGE BELOW UNLESS YOU EXACTLY KNOW WHAT YOU ARE DOING    #
 #####################################################################
 
-if [ "$gwMTA" -eq 1 ]
+if [[ "$gwMTA" -eq 1 ]]
 then
-    if [ "$debug" -eq 1 ]
+    if [[ "$debug" -eq 1 ]]
     then
         echo "DEBUG: $SERVICE gwMTA is enabled in config, checking for the process."
     fi
     gwMTAProcess=$(pgrep -x gwmta)
     if [[ -n "$gwMTAProcess" ]]
     then
-        if [ "$debug" -eq 1 ]
+        if [[ "$debug" -eq 1 ]]
         then
-            echo "DEBUG:We found a $SERVICE gwMTA process ID: $gwMTAProcess"
+            echo "DEBUG:We found a $SERVICE gwMTA process ID: $gwMTAProcess" >&2
         fi
         gwMTAListener=$(ss -lpn | grep "$gwMTAProcess" |awk '{print $5}' | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'| sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g') 
         if [[ -n "$gwMTAListener" ]]
         then
-            if [ "$debug" -eq 1 ]
+            if [[ "$debug" -eq 1 ]]
             then
-                echo "DEBUG:We found atleast one $SERVICE gwMTA listener: $gwMTAListener"
+                echo "DEBUG:We found atleast one $SERVICE gwMTA listener: $gwMTAListener" >&2
             fi
             echo "P \"$SERVICE MTA\" status=1;;;1 $SERVICE Mail Transfer Agent is running with PID: $gwMTAProcess and listening.\n $gwMTAListener"
         else
-            if [ "$debug" -eq 1 ]
+            if [[ "$debug" -eq 1 ]]
             then
-                echo "DEBUG:We found no listeners for the $SERVICE gwMTA process with process ID: $gwMTAProcess"
+                echo "DEBUG:We found no listeners for the $SERVICE gwMTA process with process ID: $gwMTAProcess" >&2
             fi
             echo "P \"$SERVICE MTA\" status=0.5;;;1 $SERVICE Mail Transfer Agent is running with PID: $gwMTAProcess but not listening."
         fi
     else
-        if [ "$debug" -eq 1 ]
+        if [[ "$debug" -eq 1 ]]
         then
             echo "DEBUG: $SERVICE gwMTA is enabled in config, but no processes could be found."
         fi
         echo "P \"$SERVICE MTA\" status=0;;;1 $SERVICE Mail Transfer Agent process is not Running."
     fi
 else
-    echo "DEBUG: $SERVICE gwMTA is not enabled in config, skipping."
+    echo "DEBUG: $SERVICE gwMTA is not enabled in config, skipping." >&2
 fi
 
-if [ "$gwPOA" -eq 1 ]
+if [[ "$gwPOA" -eq 1 ]]
 then
-     if [ "$debug" -eq 1 ]
+     if [[ "$debug" -eq 1 ]]
     then
-        echo "DEBUG: $SERVICE gwPOA is enabled in config, checking for the process."
+        echo "DEBUG: $SERVICE gwPOA is enabled in config, checking for the process." >&2
     fi
     gwPOAProcess=$(pgrep -x gwpoa)
     if [[ -n "$gwPOAProcess" ]]
     then
-        if [ "$debug" -eq 1 ]
+        if [[ "$debug" -eq 1 ]]
         then
-            echo "DEBUG:We found a $SERVICE gwPOA process ID: $gwPOAProcess"
+            echo "DEBUG:We found a $SERVICE gwPOA process ID: $gwPOAProcess" >&2
         fi
         gwPOAListener=$(ss -lpn | grep "$gwPOAProcess" |awk '{print $5}' | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' )
         if [[ -n "$gwPOAListener" ]]
         then
-            if [ "$debug" -eq 1 ]
+            if [[ "$debug" -eq 1 ]]
             then
-                echo "DEBUG:We found atleast one $SERVICE gwPOA listener: $gwPOAListener"
+                echo "DEBUG:We found atleast one $SERVICE gwPOA listener: $gwPOAListener" >&2
             fi
             echo "P \"$SERVICE POA\" status=1;;;1 $SERVICE Post Office Agent is running with PID: $gwPOAProcess and listening.\n $gwPOAListener"
         else
-            if [ "$debug" -eq 1 ]
+            if [[ "$debug" -eq 1 ]]
             then
-                echo "DEBUG:We found no listeners for the $SERVICE gwPOA process with process ID: $gwPOAProcess"
+                echo "DEBUG:We found no listeners for the $SERVICE gwPOA process with process ID: $gwPOAProcess" >&2
             fi
             echo "P \"$SERVICE POA\" status=0.5;;;1 $SERVICE Post Office Agent is running with PID: $gwPOAProcess but not listening."
         fi
     else
-        if [ "$debug" -eq 1 ]
+        if [[ "$debug" -eq 1 ]]
         then
-            echo "DEBUG: $SERVICE gwPOA is enabled in config, but no processes could be found."
+            echo "DEBUG: $SERVICE gwPOA is enabled in config, but no processes could be found." >&2
         fi
         echo "P \"$SERVICE POA\" status=0;;;1 $SERVICE Post Office Agent process is not Running."
     fi
 fi
 
-if [ "$gwIA" -eq 1 ]
+if [[ "$gwIA" -eq 1 ]]
 then
-     if [ "$debug" -eq 1 ]
+     if [[ "$debug" -eq 1 ]]
     then
-        echo "DEBUG: $SERVICE gwIA is enabled in config, checking for the process."
+        echo "DEBUG: $SERVICE gwIA is enabled in config, checking for the process." >&2
     fi
     gwIAProcess=$(pgrep -x gwia)
     if [[ -n "$gwIAProcess" ]]
@@ -125,22 +127,22 @@ then
         gwIAListener=$(ss -lpn | grep "$gwIAProcess" |awk '{print $5}' | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
         if [[ -n "$gwIAListener" ]]
         then
-            if [ "$debug" -eq 1 ]
+            if [[ "$debug" -eq 1 ]]
             then
-                echo "DEBUG:We found atleast one $SERVICE gwIA listener: $gwIAListener"
+                echo "DEBUG:We found atleast one $SERVICE gwIA listener: $gwIAListener" >&2
             fi
             echo "P \"$SERVICE GWIA\" status=1;;;1 $SERVICE Internet Agent is running with PID: $gwIAProcess and listening.\n $gwIAListener"
         else
-            if [ "$debug" -eq 1 ]
+            if [[ "$debug" -eq 1 ]]
             then
-                echo "DEBUG:We found no listeners for the $SERVICE gwIA process with process ID: $gwIAProcess"
+                echo "DEBUG:We found no listeners for the $SERVICE gwIA process with process ID: $gwIAProcess" >&2
             fi
             echo "P \"$SERVICE GWIA\" status=0.5;;;1 $SERVICE Internet Agent is running with PID: $gwIAProcess but not listening."
         fi
     else
-        if [ "$debug" -eq 1 ]
+        if [[ "$debug" -eq 1 ]]
         then
-            echo "DEBUG: $SERVICE gwIA is enabled in config, but no processes could be found."
+            echo "DEBUG: $SERVICE gwIA is enabled in config, but no processes could be found." >&2
         fi
         echo "P \"$SERVICE GWIA\" status=0;;;1 $SERVICE Internet Agent process is not Running."
     fi
@@ -149,26 +151,25 @@ fi
 gwAdminProcess=$(pgrep -f 'gwadmin\.jar')
 if [[ -n "$gwAdminProcess" ]]
 then
-    if [ "$debug" -eq 1 ]
+    if [[ "$debug" -eq 1 ]]
     then
         echo "DEBUG:We found a $SERVICE gwAdmin process ID: $gwAdminProcess"
     fi
     gwAdminListener=$(ss -lpn| grep "$gwAdminProcess" | awk '{print $5}' | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -u | sed 's/^::ffff://' | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
     if [[ -n "$gwAdminListener" ]]
     then
-        if [ "$debug" -eq 1 ]
+        if [[ "$debug" -eq 1 ]]
         then
-            echo "DEBUG:We found atleast one $SERVICE gwAdmin listener: $gwAdminListener"
+            echo "DEBUG:We found atleast one $SERVICE gwAdmin listener: $gwAdminListener" >&2
         fi
         echo "P \"$SERVICE AdminService\" status=1;;;1 $SERVICE AdminService process is running with PID: $gwAdminProcess and listening.\n $gwAdminListener"
     else
-        if [ "$debug" -eq 1 ]
+        if [[ "$debug" -eq 1 ]]
         then
-            echo "DEBUG:We found no listeners for the $SERVICE gwAdminService process with process ID: $gwAdminProcess"
+            echo "DEBUG:We found no listeners for the $SERVICE gwAdminService process with process ID: $gwAdminProcess" >&2
         fi
         echo "P \"$SERVICE AdminService\" status=0.5;;;1 $SERVICE AdminService is running with PID: $gwAdminProcess but not listening."
     fi
 else
     echo "P \"$SERVICE AdminService\" status=0;;;1 $SERVICE AdminService process is not Running."
 fi
-