groupwise.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. ################################################################
  3. # Global definitions for the script - change to fit your needs #
  4. ################################################################
  5. # process to look for if a GroupWise MailTransferAgent (MTA) is running (0 if no MTA is on the client, else set 1)
  6. gwMTA=1
  7. # process to look for if a GroupWise PostOffice (POA) is running (0 if no POA is on the client, else set 1)
  8. gwPOA=1
  9. # process to look for if a GroupWise Internet Agent (GWIA) is 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. 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' )
  64. if [ ! -z "$gwPOAListener" ]
  65. then
  66. echo "P \"Groupwise POA\" status=1;;;1 GroupWise Post Office Agent is running with PID: $gwPOAProcess and listening.\n $gwPOAListener"
  67. else
  68. echo "P \"Groupwise POA\" status=0.5;;;1GroupWise Post Office Agent is running with PID: $gwPOAProcess but not listening."
  69. fi
  70. else
  71. echo "P \"GroupWise POA\" status=0;;;1 GroupWise Post Office Agemt process is not Running."
  72. fi
  73. fi
  74. if [ $gwIA -eq 1 ]
  75. then
  76. if [ $debug -eq 1 ]
  77. then
  78. echo "DEBUG: gwIA is enabled in config, checking for the process."
  79. fi
  80. gwIAProcess=$(ps -ef | grep "gwia" | grep -v grep | awk '{print $2}')
  81. if [ ! -z "$gwIAProcess" ]
  82. then
  83. 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')
  84. if [ ! -z "$gwIAListener" ]
  85. then
  86. echo "P \"Groupwise GWIA\" status=1;;;1 GroupWise Internet Agent is running with PID: $gwIAProcess and listening.\n $gwIAListener"
  87. else
  88. echo "P \"Groupwise GWIA\" status=0.5;;;1 GroupWise Internet Agent is running with PID: $gwIAProcess but not listening."
  89. fi
  90. else
  91. echo "P \"GroupWise GWIA\" status=0;;;1 GroupWise Internet Agemt process is not Running."
  92. fi
  93. fi
  94. gwAdminProcess=$(ps -ef | grep gwadmin.jar | grep -v grep | awk '{print $2}')
  95. if [ ! -z "$gwAdminProcess" ]
  96. then
  97. echo "P \"Groupwise AdminService\" count=1;;;1 GroupWise AdminService process is running with PID: $gwAdminProcess"
  98. else
  99. echo "P \"GroupWise AdninService\" count=0;;;1 GroupWise AdminService process is not Running."
  100. fi