groupwise.sh 4.1 KB

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