1
0

groupwise.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. else
  22. echo "DEBUG: gwMTA is not enabled in config, skipping."
  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 Agemt process is not Running."
  52. fi
  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. echo "DEBUG:We found atleast one gwPOA listener: $gwPOAListener"
  72. fi
  73. echo "P \"Groupwise POA\" status=1;;;1 GroupWise Post Office Agent is running with PID: $gwPOAProcess and listening.\n $gwPOAListener"
  74. else
  75. if [ $debug -eq 1 ]
  76. then
  77. echo "DEBUG:We found no listeners for the gwPOA process with process ID: $gwPOAProcess"
  78. fi
  79. echo "P \"Groupwise POA\" status=0.5;;;1GroupWise Post Office Agent is running with PID: $gwPOAProcess but not listening."
  80. fi
  81. else
  82. if [ $debug -eq 1 ]
  83. then
  84. echo "DEBUG: gwPOA is enabled in config, but no processes could be found."
  85. fi
  86. echo "P \"GroupWise POA\" status=0;;;1 GroupWise Post Office Agemt process is not Running."
  87. fi
  88. fi
  89. if [ $gwIA -eq 1 ]
  90. then
  91. if [ $debug -eq 1 ]
  92. then
  93. echo "DEBUG: gwIA is enabled in config, checking for the process."
  94. fi
  95. gwIAProcess=$(ps -ef | grep "gwia" | grep -v grep | awk '{print $2}')
  96. if [ ! -z "$gwIAProcess" ]
  97. then
  98. 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')
  99. if [ ! -z "$gwIAListener" ]
  100. then
  101. echo "P \"Groupwise GWIA\" status=1;;;1 GroupWise Internet Agent is running with PID: $gwIAProcess and listening.\n $gwIAListener"
  102. else
  103. echo "P \"Groupwise GWIA\" status=0.5;;;1 GroupWise Internet Agent is running with PID: $gwIAProcess but not listening."
  104. fi
  105. else
  106. echo "P \"GroupWise GWIA\" status=0;;;1 GroupWise Internet Agemt process is not Running."
  107. fi
  108. fi
  109. gwAdminProcess=$(ps -ef | grep gwadmin.jar | grep -v grep | awk '{print $2}')
  110. if [ ! -z "$gwAdminProcess" ]
  111. then
  112. echo "P \"Groupwise AdminService\" count=1;;;1 GroupWise AdminService process is running with PID: $gwAdminProcess"
  113. else
  114. echo "P \"GroupWise AdninService\" count=0;;;1 GroupWise AdminService process is not Running."
  115. fi