groupwise.sh 6.3 KB

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