Guest User

Untitled

a guest
Sep 25th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #
  4. # Script to check the number of connections in a JBoss connection pool via JMX and
  5. # invoke flush() if the connection count is over a certain limit
  6. #
  7.  
  8. JBOSS_HOME=/apps/jboss-eap-4.3/jboss-as
  9. JBOSS_USER=admin
  10. JBOSS_PASSWORD=secret1
  11. JDBC_POOL_MBEAN="jboss.jca:service=ManagedConnectionPool,name=example_ds"
  12. JBOSS_URL=fenris.khill.org:1099
  13. JBOSS_INSTANCE_NAME=development
  14.  
  15. MAX_CONN_COUNT=100
  16.  
  17. CONN_COUNT=`$JBOSS_HOME/bin/twiddle.sh --server=$JBOSS_URL -u $JBOSS_USER -p $JBOSS_PASSWORD get $JDBC_POOL_MBEAN InUseConnectionCount | cut -d "=" -f 2`
  18.  
  19. if [ $CONN_COUNT -ge $MAX_CONN_COUNT ]; then
  20. echo "Connection pool has exceeded maximum size!"
  21. # invoke a thread dump
  22. kill -3 `ps auxw | grep java | grep $JBOSS_INSTANCE_NAME | grep -v grep | awk '{print $2}'`
  23. # wait a bit and take another dump
  24. echo "Sleeping for 10 seconds before second thread dump..."
  25. sleep 10
  26. kill -3 `ps auxw | grep java | grep $JBOSS_INSTANCE_NAME | grep -v grep | awk '{print $2}'`
  27. echo "Thread dumps completed. Flushing JDBC connection pool..."
  28. # flush the JDBC Pool
  29. $JBOSS_HOME/bin/twiddle.sh --server=$JBOSS_URL -u $JBOSS_USER -p $JBOSS_PASSWORD invoke $JDBC_POOL_MBEAN flush
  30. echo "Recovery complete"
  31. else
  32. echo "Connection count $CONN_COUNT is within acceptable limits"
  33. fi
Add Comment
Please, Sign In to add comment