Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Script to check the number of connections in a JBoss connection pool via JMX and
- # invoke flush() if the connection count is over a certain limit
- #
- JBOSS_HOME=/apps/jboss-eap-4.3/jboss-as
- JBOSS_USER=admin
- JBOSS_PASSWORD=secret1
- JDBC_POOL_MBEAN="jboss.jca:service=ManagedConnectionPool,name=example_ds"
- JBOSS_URL=fenris.khill.org:1099
- JBOSS_INSTANCE_NAME=development
- MAX_CONN_COUNT=100
- 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`
- if [ $CONN_COUNT -ge $MAX_CONN_COUNT ]; then
- echo "Connection pool has exceeded maximum size!"
- # invoke a thread dump
- kill -3 `ps auxw | grep java | grep $JBOSS_INSTANCE_NAME | grep -v grep | awk '{print $2}'`
- # wait a bit and take another dump
- echo "Sleeping for 10 seconds before second thread dump..."
- sleep 10
- kill -3 `ps auxw | grep java | grep $JBOSS_INSTANCE_NAME | grep -v grep | awk '{print $2}'`
- echo "Thread dumps completed. Flushing JDBC connection pool..."
- # flush the JDBC Pool
- $JBOSS_HOME/bin/twiddle.sh --server=$JBOSS_URL -u $JBOSS_USER -p $JBOSS_PASSWORD invoke $JDBC_POOL_MBEAN flush
- echo "Recovery complete"
- else
- echo "Connection count $CONN_COUNT is within acceptable limits"
- fi
Add Comment
Please, Sign In to add comment