Преглед изворни кода

Corrected qutation use throuhout the scrit making it more coherent, bumped version to 1.2

Michael Honkoop пре 1 недеља
родитељ
комит
7ef9ff3648
1 измењених фајлова са 32 додато и 24 уклоњено
  1. 32 24
      localchecks/groupwise.sh

+ 32 - 24
localchecks/groupwise.sh

@@ -4,6 +4,14 @@
 
 # License: GNU General Public License v2
 
+# v1.0:
+# - Initial release of the script
+# v1.1:
+# - Aligned quotation marks around variables cosistently
+
+# Current active version of the script
+SCRIPT_VERSION=1.1
+
 ################################################################
 # Global definitions for the script - change to fit your needs #
 ################################################################
@@ -24,36 +32,36 @@ debug=0
 # 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: gwMTA is enabled in config, checking for the process."
     fi
     gwMTAProcess=$(ps -ef | grep "gwmta" | grep -v grep | awk '{print $2}')
     if [ ! -z "$gwMTAProcess" ]
     then
-        if [ $debug -eq 1 ]
+        if [ "$debug" -eq 1 ]
         then
             echo "DEBUG:We found a gwMTA process ID: $gwMTAProcess"
         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') 
+        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 [ ! -z "$gwMTAListener" ]
         then
-            if [ $debug -eq 1 ]
+            if [ "$debug" -eq 1 ]
             then
                 echo "DEBUG:We found atleast one gwMTA listener: $gwMTAListener"
             fi
             echo "P \"Groupwise MTA\" status=1;;;1 GroupWise 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 gwMTA process with process ID: $gwMTAProcess"
             fi
             echo "P \"Groupwise MTA\" status=0.5;;;1GroupWise Mail Transfer Agent is running with PID: $gwMTAProcess but not listening."
         fi
     else
-        if [ $debug -eq 1 ]
+        if [ "$debug" -eq 1 ]
         then
             echo "DEBUG: gwMTA is enabled in config, but no processes could be found."
         fi
@@ -63,36 +71,36 @@ else
     echo "DEBUG: gwMTA is not enabled in config, skipping."
 fi
 
-if [ $gwPOA -eq 1 ]
+if [ "$gwPOA" -eq 1 ]
 then
-     if [ $debug -eq 1 ]
+     if [ "$debug" -eq 1 ]
     then
         echo "DEBUG: gwPOA is enabled in config, checking for the process."
     fi
     gwPOAProcess=$(ps -ef | grep "gwpoa" | grep -v grep | awk '{print $2}')
     if [ ! -z "$gwPOAProcess" ]
     then
-        if [ $debug -eq 1 ]
+        if [ "$debug" -eq 1 ]
         then
             echo "DEBUG:We found a gwPOA process ID: $gwPOAProcess"
         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' )
+        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 [ ! -z "$gwPOAListener" ]
         then
-            if [ $debug -eq 1 ]
+            if [ "$debug" -eq 1 ]
             then
                 echo "DEBUG:We found atleast one gwPOA listener: $gwPOAListener"
             fi
             echo "P \"Groupwise POA\" status=1;;;1 GroupWise 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 gwPOA process with process ID: $gwPOAProcess"
             fi
             echo "P \"Groupwise POA\" status=0.5;;;1GroupWise Post Office Agent is running with PID: $gwPOAProcess but not listening."
         fi
     else
-        if [ $debug -eq 1 ]
+        if [ "$debug" -eq 1 ]
         then
             echo "DEBUG: gwPOA is enabled in config, but no processes could be found."
         fi
@@ -100,32 +108,32 @@ then
     fi
 fi
 
-if [ $gwIA -eq 1 ]
+if [ "$gwIA" -eq 1 ]
 then
-     if [ $debug -eq 1 ]
+     if [ "$debug" -eq 1 ]
     then
         echo "DEBUG: gwIA is enabled in config, checking for the process."
     fi
     gwIAProcess=$(ps -ef | grep "gwia" | grep -v grep | awk '{print $2}')
     if [ ! -z "$gwIAProcess" ]
     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')
+        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 [ ! -z "$gwIAListener" ]
         then
-            if [ $debug -eq 1 ]
+            if [ "$debug" -eq 1 ]
             then
                 echo "DEBUG:We found atleast one gwIA listener: $gwIAListener"
             fi
             echo "P \"Groupwise GWIA\" status=1;;;1 GroupWise 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 gwIA process with process ID: $gwIAProcess"
             fi
             echo "P \"Groupwise GWIA\" status=0.5;;;1 GroupWise Internet Agent is running with PID: $gwIAProcess but not listening."
         fi
     else
-        if [ $debug -eq 1 ]
+        if [ "$debug" -eq 1 ]
         then
             echo "DEBUG: gwIA is enabled in config, but no processes could be found."
         fi
@@ -136,20 +144,20 @@ fi
 gwAdminProcess=$(ps -ef | grep gwadmin.jar | grep -v grep | awk '{print $2}')
 if [ ! -z "$gwAdminProcess" ]
 then
-    if [ $debug -eq 1 ]
+    if [ "$debug" -eq 1 ]
     then
         echo "DEBUG:We found a 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')
+    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 [ ! -z "$gwAdminListener" ]
     then
-        if [ $debug -eq 1 ]
+        if [ "$debug" -eq 1 ]
         then
             echo "DEBUG:We found atleast one gwAdmin listener: $gwAdminListener"
         fi
         echo "P \"Groupwise AdminService\" count=1;;;1 GroupWise 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 gwAdminService process with process ID: $gwAdminProcess"
         fi