groupwise.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 (leave blank if no MTA is on the client)
  6. gwMTA=1
  7. # process to look for if a GroupWise PostOffice (POA) is running (leave blank if no POA is on the client)
  8. gwPOA=1
  9. # process to look for if a GroupWise Internet Agent (GWIA) is running (leave blank if no GWIA is on the client)
  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: gwMTA is enabled and we found a 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. echo "P \"Groupwise MTA\" status=1;;;1 GroupWise Mail Transfer Agent is running with PID: $gwMTAProcess and listening.\n $gwMTAListener"
  35. else
  36. echo "P \"Groupwise MTA\" status=0.5;;;1GroupWise Mail Transfer Agent is running with PID: $gwMTAProcess but not listening."
  37. fi
  38. else
  39. echo "P \"GroupWise MTA\" status=0;;;1 GroupWise Mail Transfer Agemt process is not Running."
  40. fi
  41. fi
  42. if [ $gwPOA -eq 1 ]
  43. then
  44. if [ $debug -eq 1 ]
  45. then
  46. echo "DEBUG: gwPOA is enabled in config, checking for the process."
  47. fi
  48. gwPOAProcess=$(ps -ef | grep "gwpoa" | grep -v grep | awk '{print $2}')
  49. if [ ! -z "$gwPOAProcess" ]
  50. then
  51. 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' )
  52. if [ ! -z "$gwPOAListener" ]
  53. then
  54. echo "P \"Groupwise POA\" status=1;;;1 GroupWise Post Office Agent is running with PID: $gwPOAProcess and listening.\n $gwPOAListener"
  55. else
  56. echo "P \"Groupwise POA\" status=0.5;;;1GroupWise Post Office Agent is running with PID: $gwPOAProcess but not listening."
  57. fi
  58. else
  59. echo "P \"GroupWise POA\" status=0;;;1 GroupWise Post Office Agemt process is not Running."
  60. fi
  61. fi
  62. if [ $gwIA -eq 1 ]
  63. then
  64. if [ $debug -eq 1 ]
  65. then
  66. echo "DEBUG: gwIA is enabled in config, checking for the process."
  67. fi
  68. gwIAProcess=$(ps -ef | grep "gwia" | grep -v grep | awk '{print $2}')
  69. if [ ! -z "$gwIAProcess" ]
  70. then
  71. 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')
  72. if [ ! -z "$gwIAListener" ]
  73. then
  74. echo "P \"Groupwise GWIA\" status=1;;;1 GroupWise Internet Agent is running with PID: $gwIAProcess and listening.\n $gwIAListener"
  75. else
  76. echo "P \"Groupwise GWIA\" status=0.5;;;1 GroupWise Internet Agent is running with PID: $gwIAProcess but not listening."
  77. fi
  78. else
  79. echo "P \"GroupWise GWIA\" status=0;;;1 GroupWise Internet Agemt process is not Running."
  80. fi
  81. fi
  82. gwAdminProcess=$(ps -ef | grep gwadmin.jar | grep -v grep | awk '{print $2}')
  83. if [ ! -z "$gwAdminProcess" ]
  84. then
  85. echo "P \"Groupwise AdminService\" count=1;;;1 GroupWise AdminService process is running with PID: $gwAdminProcess"
  86. else
  87. echo "P \"GroupWise AdninService\" count=0;;;1 GroupWise AdminService process is not Running."
  88. fi