You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ai...@apache.org on 2009/01/08 16:41:18 UTC
svn commit: r732729 - /qpid/trunk/qpid/java/broker/scripts/resetAlerting.sh
Author: aidan
Date: Thu Jan 8 07:41:18 2009
New Revision: 732729
URL: http://svn.apache.org/viewvc?rev=732729&view=rev
Log:
Improve error handling, help
Modified:
qpid/trunk/qpid/java/broker/scripts/resetAlerting.sh
Modified: qpid/trunk/qpid/java/broker/scripts/resetAlerting.sh
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/scripts/resetAlerting.sh?rev=732729&r1=732728&r2=732729&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/scripts/resetAlerting.sh (original)
+++ qpid/trunk/qpid/java/broker/scripts/resetAlerting.sh Thu Jan 8 07:41:18 2009
@@ -5,21 +5,52 @@
# Defaults to Localhost broker
#
-CLI=./build/bin/qpid-cli
+if [ -z "$QPID_ALERT_HOME" ]; then
+ export QPID_ALERT_HOME=$(dirname $(dirname $(readlink -f $0)))
+ export PATH=${PATH}:${QPID_ALERT_HOME}/bin
+fi
+
+USERNAME=$1
+PASSWORD=$2
+HOSTNAME=$3
+PORT=$4
+
+CLI="$QPID_ALERT_HOME/bin/qpid-cli -h ${HOSTNAME:-localhost} -p ${PORT:-8999}"
+AUTH=
+if [ -n $USERNAME ] ; then
+ if [ "$USERNAME" == "-h" ] ; then
+ echo "resetAlerting.sh: [<username> <password> [<hostname> [<port>]]]"
+ exit 0
+ fi
+ if [ -n $PASSWORD ] ; then
+ AUTH="-u $USERNAME -w $PASSWORD"
+ else
+ echo "Password must be specified with username"
+ fi
+fi
+
+
OUTPUT=0
+runCommand()
+{
+ RET=`$CLI $1 $AUTH`
+}
resetQueue()
{
vhost=$1
queue=$2
- echo "Resetting Values for $queue on $vhost"
- rawQDepth=`$CLI get -o queue -v $vhost -n $queue -a MaximumQueueDepth`
- # Note that MaxQueDepth is returned as Kb but set as b!
+ runCommand "get -o queue -v $vhost -n $queue -a MaximumQueueDepth"
+ rawQDepth=$RET
+ # Note that MaxQueueDepth is returned as Kb but set as b!
queueDepth=$[ $rawQDepth * 1024 ]
- messageAge=`$CLI get -o queue -v $vhost -n $queue -a MaximumMessageAge`
- messageCount=`$CLI get -o queue -v $vhost -n $queue -a MaximumMessageCount`
- messageSize=`$CLI get -o queue -v $vhost -n $queue -a MaximumMessageSize`
+ runCommand "get -o queue -v $vhost -n $queue -a MaximumMessageAge"
+ messageAge=$RET
+ runCommand "get -o queue -v $vhost -n $queue -a MaximumMessageCount"
+ messageCount=$RET
+ runCommand "get -o queue -v $vhost -n $queue -a MaximumMessageSize"
+ messageSize=$RET
if [ $OUTPUT == 1 ] ; then
echo Current Values:
@@ -29,30 +60,36 @@
echo MaximumMessageSize : $messageSize
fi
- $CLI set -o queue -v $vhost -n $queue -a MaximumMessageSize -s $messageSize
- $CLI set -o queue -v $vhost -n $queue -a MaximumMessageAge -s $messageAge
- $CLI set -o queue -v $vhost -n $queue -a MaximumMessageCount -s $messageCount
- $CLI set -o queue -v $vhost -n $queue -a MaximumQueueDepth -s $queueDepth
+ runCommand "set -o queue -v $vhost -n $queue -a MaximumMessageSize -s $messageSize"
+ runCommand "set -o queue -v $vhost -n $queue -a MaximumMessageAge -s $messageAge"
+ runCommand "set -o queue -v $vhost -n $queue -a MaximumMessageCount -s $messageCount"
+ runCommand "set -o queue -v $vhost -n $queue -a MaximumQueueDepth -s $queueDepth"
}
resetVirtualHost()
{
vhost=$1
ignore=0
- for queue in `$CLI list -o queue -v $vhost |grep '|' | cut -d '|' -f 1 ` ; do
+ for queue in `$CLI list -o queue -v $vhost $AUTH |grep '|' | cut -d '|' -f 1 ` ; do
if [ $ignore == 0 ] ; then
ignore=1
- else
+ else
resetQueue $vhost $queue
fi
done
}
-for vhost in `$CLI list -o virtualhost|grep VirtualHost|cut -d '=' -f 3` ; do
-
- resetVirtualHost $vhost
-
-done
-
+VHOST=`$CLI list -o virtualhost $AUTH`
+COUNT=`echo $VHOST | grep -c VirtualHost`
+if [ $COUNT -gt 0 ] ; then
+ for vhost in `echo $VHOST |grep VirtualHost|cut -d '=' -f 3` ; do
+
+ echo "Resetting alert levels for $vhost";
+ resetVirtualHost $vhost;
+ done
+ echo "Alerting levels reset"
+else
+ echo $VHOST
+fi