1
0

groupwise.sh 6.4 KB

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