1
0

groupwise.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #!/bin/bash
  2. # (c) Michael Honkoop <mhonkoop@comsolve.nl>
  3. # License: GNU General Public License v2
  4. # v1.0:
  5. # - Initial release of the script
  6. # v1.1:
  7. # - Aligned quotation marks around variables cosistently
  8. # Current active version of the script
  9. SCRIPT_VERSION=1.1
  10. ################################################################
  11. # Global definitions for the script - change to fit your needs #
  12. ################################################################
  13. # Look for a process if a GroupWise MailTransferAgent (MTA) should be running (0 if no MTA is on the client, else set 1)
  14. gwMTA=1
  15. # Look for a process if a GroupWise PostOffice (POA) should be running (0 if no POA is on the client, else set 1)
  16. gwPOA=1
  17. # Look for a process if a GroupWise Internet Agent (GWIA) should be running (0 if no GWIA is on the client, else set 1)
  18. gwIA=1
  19. # Debug switch for development purposes ( 0 for no debug, 1 for debug information )
  20. debug=0
  21. #####################################################################
  22. # DO NOT CHANGE BELOW UNLESS YOU EXACTLY KNOW WHAT YOU ARE DOING #
  23. #####################################################################
  24. if [ "$gwMTA" -eq 1 ]
  25. then
  26. if [ "$debug" -eq 1 ]
  27. then
  28. echo "DEBUG: gwMTA is enabled in config, checking for the process."
  29. fi
  30. gwMTAProcess=$(ps -ef | grep "gwmta" | grep -v grep | awk '{print $2}')
  31. if [ ! -z "$gwMTAProcess" ]
  32. then
  33. if [ "$debug" -eq 1 ]
  34. then
  35. echo "DEBUG:We found a gwMTA process ID: $gwMTAProcess"
  36. fi
  37. 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')
  38. if [ ! -z "$gwMTAListener" ]
  39. then
  40. if [ "$debug" -eq 1 ]
  41. then
  42. echo "DEBUG:We found atleast one gwMTA listener: $gwMTAListener"
  43. fi
  44. echo "P \"Groupwise MTA\" status=1;;;1 GroupWise Mail Transfer Agent is running with PID: $gwMTAProcess and listening.\n $gwMTAListener"
  45. else
  46. if [ "$debug" -eq 1 ]
  47. then
  48. echo "DEBUG:We found no listeners for the gwMTA process with process ID: $gwMTAProcess"
  49. fi
  50. echo "P \"Groupwise MTA\" status=0.5;;;1GroupWise Mail Transfer Agent is running with PID: $gwMTAProcess but not listening."
  51. fi
  52. else
  53. if [ "$debug" -eq 1 ]
  54. then
  55. echo "DEBUG: gwMTA is enabled in config, but no processes could be found."
  56. fi
  57. echo "P \"GroupWise MTA\" status=0;;;1 GroupWise Mail Transfer Agent process is not Running."
  58. fi
  59. else
  60. echo "DEBUG: gwMTA is not enabled in config, skipping."
  61. fi
  62. if [ "$gwPOA" -eq 1 ]
  63. then
  64. if [ "$debug" -eq 1 ]
  65. then
  66. echo "DEBUG: gwPOA is enabled in config, checking for the process."
  67. fi
  68. gwPOAProcess=$(ps -ef | grep "gwpoa" | grep -v grep | awk '{print $2}')
  69. if [ ! -z "$gwPOAProcess" ]
  70. then
  71. if [ "$debug" -eq 1 ]
  72. then
  73. echo "DEBUG:We found a gwPOA process ID: $gwPOAProcess"
  74. fi
  75. 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' )
  76. if [ ! -z "$gwPOAListener" ]
  77. then
  78. if [ "$debug" -eq 1 ]
  79. then
  80. echo "DEBUG:We found atleast one gwPOA listener: $gwPOAListener"
  81. fi
  82. echo "P \"Groupwise POA\" status=1;;;1 GroupWise Post Office Agent is running with PID: $gwPOAProcess and listening.\n $gwPOAListener"
  83. else
  84. if [ "$debug" -eq 1 ]
  85. then
  86. echo "DEBUG:We found no listeners for the gwPOA process with process ID: $gwPOAProcess"
  87. fi
  88. echo "P \"Groupwise POA\" status=0.5;;;1GroupWise Post Office Agent is running with PID: $gwPOAProcess but not listening."
  89. fi
  90. else
  91. if [ "$debug" -eq 1 ]
  92. then
  93. echo "DEBUG: gwPOA is enabled in config, but no processes could be found."
  94. fi
  95. echo "P \"GroupWise POA\" status=0;;;1 GroupWise Post Office Agent process is not Running."
  96. fi
  97. fi
  98. if [ "$gwIA" -eq 1 ]
  99. then
  100. if [ "$debug" -eq 1 ]
  101. then
  102. echo "DEBUG: gwIA is enabled in config, checking for the process."
  103. fi
  104. gwIAProcess=$(ps -ef | grep "gwia" | grep -v grep | awk '{print $2}')
  105. if [ ! -z "$gwIAProcess" ]
  106. then
  107. 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')
  108. if [ ! -z "$gwIAListener" ]
  109. then
  110. if [ "$debug" -eq 1 ]
  111. then
  112. echo "DEBUG:We found atleast one gwIA listener: $gwIAListener"
  113. fi
  114. echo "P \"Groupwise GWIA\" status=1;;;1 GroupWise Internet Agent is running with PID: $gwIAProcess and listening.\n $gwIAListener"
  115. else
  116. if [ "$debug" -eq 1 ]
  117. then
  118. echo "DEBUG:We found no listeners for the gwIA process with process ID: $gwIAProcess"
  119. fi
  120. echo "P \"Groupwise GWIA\" status=0.5;;;1 GroupWise Internet Agent is running with PID: $gwIAProcess but not listening."
  121. fi
  122. else
  123. if [ "$debug" -eq 1 ]
  124. then
  125. echo "DEBUG: gwIA is enabled in config, but no processes could be found."
  126. fi
  127. echo "P \"GroupWise GWIA\" status=0;;;1 GroupWise Internet Agent process is not Running."
  128. fi
  129. fi
  130. gwAdminProcess=$(ps -ef | grep gwadmin.jar | grep -v grep | awk '{print $2}')
  131. if [ ! -z "$gwAdminProcess" ]
  132. then
  133. if [ "$debug" -eq 1 ]
  134. then
  135. echo "DEBUG:We found a gwAdmin process ID: $gwAdminProcess"
  136. fi
  137. 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')
  138. if [ ! -z "$gwAdminListener" ]
  139. then
  140. if [ "$debug" -eq 1 ]
  141. then
  142. echo "DEBUG:We found atleast one gwAdmin listener: $gwAdminListener"
  143. fi
  144. echo "P \"Groupwise AdminService\" count=1;;;1 GroupWise AdminService process is running with PID: $gwAdminProcess and listening.\n $gwAdminListener"
  145. else
  146. if [ "$debug" -eq 1 ]
  147. then
  148. echo "DEBUG:We found no listeners for the gwAdminService process with process ID: $gwAdminProcess"
  149. fi
  150. echo "P \"Groupwise AdminService\" status=0.5;;;1 GroupWise AdminService is running with PID: $gwAdminProcess but not listening."
  151. fi
  152. else
  153. echo "P \"GroupWise AdminService\" status=0;;;1 GroupWise AdminService process is not Running."
  154. fi