Omaha #3799 Upgraded QPID to version 0.32
Former-commit-id: bede2a938cdc5b97d288a79b41ef5123a8cb75bd
This commit is contained in:
parent
d0a93c7e53
commit
cdd4141d18
10 changed files with 7 additions and 1027 deletions
|
@ -1,355 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# script to gather information on a qpid host
|
||||
# 20 July 2012 - Initial script (kpj)
|
||||
|
||||
|
||||
function setupEnv() {
|
||||
|
||||
runTimeDate=$( date +"%Y%m%d %H:%M:%S" )
|
||||
nowTimeDate=$( date +%A )
|
||||
logDirectory=/data/fxa/qpid
|
||||
logName=$( basename $0 .sh ).${nowTimeDate}.log
|
||||
nasHost=nas1
|
||||
nasVolName=dataFXA # This is so we can change it for new nas!
|
||||
lsofCommand="lsof -Pns -p"
|
||||
platformName=$( hostname | cut -f2 -d'-')
|
||||
|
||||
if [[ ${logDirectory}/${logName} -ot ${logDirectory}/$( basename $0 .sh ).$(date --date='1 day ago' +%A).log ]]
|
||||
then
|
||||
for myFile in ${logName} ${nowTimeDate}-lsof_qpid.out ${nowTimeDate}-qpid-stat.out ${nowTimeDate}-netstat.out ${nowTimeDate}-ipvsadm.out ${nowTimeDate}-captureQpidHeapInfo.out
|
||||
do
|
||||
echo > ${logDirectory}/${myFile}
|
||||
done
|
||||
gzip -f ${logDirectory}/*$(date --date='1 day ago' +%A)*
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
function color_echo() {
|
||||
|
||||
# To echo something to stdout with color
|
||||
#
|
||||
# Usage: color_echo $COLOR $BOLD $STRING
|
||||
#
|
||||
# COLOR: Color string from: black, green, blue, red, yellow, white
|
||||
# BOLD: 1 = true, 0 = false
|
||||
# STRING: String to echo
|
||||
|
||||
sColor=$1
|
||||
sBold=$2
|
||||
sString=$3
|
||||
|
||||
if [[ -z "${sColor}" || -z "${sBold}" || -z "${sString}" ]] || [[ ${sBold} -ne 1 && ${sBold} -ne 0 ]]
|
||||
then
|
||||
echo -e "ERROR IN $FUNCNAME:\t Usage:\t$FUNCNAME $COLOR $BOLD $STRING"
|
||||
else
|
||||
case ${sColor} in
|
||||
"green" ) colorInt=32 ;;
|
||||
"blue" ) colorInt=34 ;;
|
||||
"red" ) colorInt=31 ;;
|
||||
"yellow" ) colorInt=33 ;;
|
||||
"white" ) colorInt=37 ;;
|
||||
"black" ) colorInt=30 ;;
|
||||
* ) colorInt="" ;;
|
||||
esac
|
||||
|
||||
if [[ ${sBold} -eq 0 ]]; then sBold="" ; fi
|
||||
echo -e "\033[${sBold};${colorInt}m${sString}\033[0m"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function echoDate() {
|
||||
|
||||
echo -ne "|-- $( date +"%Y%m%d %H:%M:%S" )"
|
||||
|
||||
}
|
||||
|
||||
function echoFail() {
|
||||
|
||||
echoDate && color_echo red 1 "\t$1"
|
||||
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
|
||||
if [[ "${hadToMount}" ]]
|
||||
then
|
||||
umount /data/fxa
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function runlsof() {
|
||||
|
||||
echo -ne "\n| START " >> ${logDirectory}/${nowTimeDate}-lsof_qpid.out
|
||||
echoDate >> ${logDirectory}/${nowTimeDate}-lsof_qpid.out
|
||||
echo -e "----------------------------------------------------------------|\n" >> ${logDirectory}/${nowTimeDate}-lsof_qpid.out
|
||||
|
||||
if ${lsofCommand} ${qpidPid} >> ${logDirectory}/${nowTimeDate}-lsof_qpid.out 2>&1
|
||||
then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function captureQpidStat() {
|
||||
|
||||
local returnCode=0
|
||||
local qpidConnLimit=500
|
||||
local qpidConnMedAlarm=75
|
||||
local qpidConnHighAlarm=40
|
||||
local qpidConnCritAlarm=15
|
||||
|
||||
case "${platformName}" in
|
||||
[a-z][a-z][a-z]n ) qpidConnLimit=1000 ; echo -e "\tNOTE: Setting Max qpidd connection to 1000 due to NCEP site" >> ${logDirectory}/${nowTimeDate}-qpid-stat.out ;;
|
||||
esac
|
||||
|
||||
echo -ne "\n| START " >> ${logDirectory}/${nowTimeDate}-qpid-stat.out
|
||||
echoDate >> ${logDirectory}/${nowTimeDate}-qpid-stat.out
|
||||
echo -e "----------------------------------------------------------------|\n" >> ${logDirectory}/${nowTimeDate}-qpid-stat.out
|
||||
|
||||
# Send ITO alarm to NCF - Thank you Sean Bowser for your guidance here. You are wise.
|
||||
numQpidConnections=$( qpid-stat -c | wc -l )
|
||||
(( numQpidConnections-=3 ))
|
||||
echo -e "Total Number of QPID Connections: ${numQpidConnections}" >> ${logDirectory}/${nowTimeDate}-qpid-stat.out
|
||||
|
||||
echo >> ${logDirectory}/${nowTimeDate}-qpid-stat.out
|
||||
|
||||
for cmdArg in "-b" "-c" "-s" "-e" "-q -Smsg"
|
||||
do
|
||||
if ! qpid-stat ${cmdArg} >> ${logDirectory}/${nowTimeDate}-qpid-stat.out 2>&1
|
||||
then
|
||||
(( returnCode+=1 ))
|
||||
echoFail "\tqpid-stat ${cmdArg} returned non-zero exit code"
|
||||
fi
|
||||
echo >> ${logDirectory}/${nowTimeDate}-qpid-stat.out
|
||||
done
|
||||
|
||||
return ${returnCode}
|
||||
}
|
||||
|
||||
function captureNetstat() {
|
||||
|
||||
echo -ne "\n| START " >> ${logDirectory}/${nowTimeDate}-netstat.out
|
||||
echoDate >> ${logDirectory}/${nowTimeDate}-netstat.out
|
||||
echo -e "----------------------------------------------------------------|\n" >> ${logDirectory}/${nowTimeDate}-netstat.out
|
||||
|
||||
if netstat -tunape | grep :5672 >> ${logDirectory}/${nowTimeDate}-netstat.out 2>&1
|
||||
then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function captureIPVS() {
|
||||
|
||||
local returnCode=0
|
||||
|
||||
echo -ne "\n| START " >> ${logDirectory}/${nowTimeDate}-ipvsadm.out 2>&1
|
||||
echoDate >> ${logDirectory}/${nowTimeDate}-ipvsadm.out 2>&1
|
||||
echo -e "----------------------------------------------------------------|\n" >> ${logDirectory}/${nowTimeDate}-ipvsadm.out 2>&1
|
||||
|
||||
if ! ipvsadm --list >> ${logDirectory}/${nowTimeDate}-ipvsadm.out 2>&1
|
||||
then
|
||||
(( returnCode+=1 ))
|
||||
fi
|
||||
echo >> ${logDirectory}/${nowTimeDate}-ipvsadm.out
|
||||
|
||||
if ! ipvsadm --list --stats >> ${logDirectory}/${nowTimeDate}-ipvsadm.out 2>&1
|
||||
then
|
||||
(( returnCode+=1 ))
|
||||
fi
|
||||
echo >> ${logDirectory}/${nowTimeDate}-ipvsadm.out
|
||||
|
||||
if ! ipvsadm --list --connection --sort >> ${logDirectory}/${nowTimeDate}-ipvsadm.out 2>&1
|
||||
then
|
||||
(( returnCode+=1 ))
|
||||
fi
|
||||
echo >> ${logDirectory}/${nowTimeDate}-ipvsadm.out
|
||||
|
||||
return ${returnCode}
|
||||
}
|
||||
|
||||
function captureQpidHeapInfo() {
|
||||
|
||||
|
||||
local returnCode=0
|
||||
local logFile=${logDirectory}/${nowTimeDate}-$FUNCNAME.out
|
||||
|
||||
echo -ne "\n| START " >> ${logFile} 2>&1
|
||||
echoDate >> ${logFile} 2>&1
|
||||
echo -e "----------------------------------------------------------------|\n" >> ${logFile} 2>&1
|
||||
|
||||
#qpidPid=$( jps -v | grep QPBRKR | awk '{print $1}' )
|
||||
|
||||
if ! ps -p ${qpidPid} > /dev/null ; then
|
||||
echoFail "\tCan not find returned qpidd pid (${qpidPid}): $( jps -v | grep QPBRKR | awk '{print $1}' )"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "\tFound qpidd on PID ${qpidPid}" >> ${logFile}
|
||||
|
||||
echo -e "\tGetting HEAP usage...........................\n\n" >> ${logFile}
|
||||
jmap -heap ${qpidPid} | while read line ; do
|
||||
echo -e "\t\t${line}" >> ${logFile}
|
||||
done
|
||||
|
||||
echo -e "\n\n\tGetting Garbage Collection Information ..................\n\n" >> ${logFile}
|
||||
jstat -gcutil ${qpidPid} 1000 30 | while read line ; do
|
||||
echo -e "\t\t${line}" >> ${logFile}
|
||||
done
|
||||
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
## main()
|
||||
setupEnv
|
||||
|
||||
{
|
||||
|
||||
echo -ne "\n| START " && echoDate && echo -e "----------------------------------------------------------------|\n"
|
||||
|
||||
if ! grep /data/fxa /proc/mounts | grep nfs 2>&1 > /dev/null
|
||||
then
|
||||
# /data/fxa isn't an nfs mount
|
||||
if mount ${nasHost}:${nasVolName} /data/fxa
|
||||
then
|
||||
hadToMount=true
|
||||
else
|
||||
echoFail "ERROR:\t Couldn't mount /data/fxa and that is where the log goes!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# now check write permission
|
||||
if [[ ! -d ${logDirectory} ]]
|
||||
then
|
||||
if ! mkdir -p ${logDirectory} > /dev/null 2>&1
|
||||
then
|
||||
echoFail "ERROR:\t Couldn't create ${logDirectory}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! touch ${logDirectory}/testfile > /dev/null 2>&1
|
||||
then
|
||||
echoFail "ERROR:\tNo write permissions to ${logDirectory}"
|
||||
exit 1
|
||||
else
|
||||
rm ${logDirectory}/testfile
|
||||
fi
|
||||
|
||||
if ! qpidPid=$( jps -v | grep QPBRKR | awk '{print $1}' )
|
||||
then
|
||||
echoFail "ERROR:\tCan't find qpidd on this host (run: jps -v | grep QPBRKR failed)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
runlsof &
|
||||
functionPID=$!
|
||||
_cnt=0
|
||||
while ps -p ${functionPID} > /dev/null
|
||||
do
|
||||
sleep 1
|
||||
_cnt=$(($_cnt+1))
|
||||
if [[ ${_cnt} -ge 10 ]]
|
||||
then
|
||||
kill -9 ${functionPID}
|
||||
echoFail "ERROR: lsof running for more than 10 seconds, killing"
|
||||
fi
|
||||
done
|
||||
|
||||
if ! wait ${functionPID}
|
||||
then
|
||||
echoFail "ERROR: Grabbing of lsof on qpidd failed"
|
||||
fi
|
||||
|
||||
|
||||
captureQpidStat &
|
||||
functionPID=$!
|
||||
_cnt=0
|
||||
while ps -p ${functionPID} > /dev/null
|
||||
do
|
||||
sleep 1
|
||||
_cnt=$(($_cnt+1))
|
||||
if [[ ${_cnt} -ge 30 ]]
|
||||
then
|
||||
kill -9 ${functionPID}
|
||||
echoFail "ERROR: qpid-stat running for more than 30 seconds, killing"
|
||||
fi
|
||||
done
|
||||
|
||||
if ! wait ${functionPID}
|
||||
then
|
||||
echoFail "ERROR: Grabbing of qpid-stat failed"
|
||||
fi
|
||||
|
||||
captureQpidHeapInfo &
|
||||
functionPID=$!
|
||||
_cnt=0
|
||||
while ps -p ${functionPID} > /dev/null
|
||||
do
|
||||
sleep 1
|
||||
_cnt=$(($_cnt+1))
|
||||
if [[ ${_cnt} -ge 60 ]]
|
||||
then
|
||||
kill -9 ${functionPID}
|
||||
echoFail "ERROR: Getting heap infomation running for more than 60 seconds, killing"
|
||||
fi
|
||||
done
|
||||
|
||||
if ! wait ${functionPID}
|
||||
then
|
||||
echoFail "ERROR: Grabbing of heap utilization failed"
|
||||
fi
|
||||
|
||||
captureNetstat &
|
||||
functionPID=$!
|
||||
_cnt=0
|
||||
while ps -p ${functionPID} > /dev/null
|
||||
do
|
||||
sleep 1
|
||||
_cnt=$(($_cnt+1))
|
||||
if [[ ${_cnt} -ge 10 ]]
|
||||
then
|
||||
kill -9 ${functionPID}
|
||||
echoFail "ERROR: netstat running for more than 10 seconds, killing"
|
||||
fi
|
||||
done
|
||||
|
||||
if ! wait ${functionPID}
|
||||
then
|
||||
echoFail "ERROR: Grabbing of netstat failed"
|
||||
fi
|
||||
|
||||
if ! pidof pulse > /dev/null 2>&1
|
||||
then
|
||||
echoFail "ERROR: IPVS doesn't appear to be running on this host ($( hostname ))"
|
||||
else
|
||||
captureIPVS &
|
||||
functionPID=$!
|
||||
_cnt=0
|
||||
while ps -p ${functionPID} > /dev/null
|
||||
do
|
||||
sleep 1
|
||||
_cnt=$(($_cnt+1))
|
||||
if [[ ${_cnt} -ge 20 ]]
|
||||
then
|
||||
kill -9 ${functionPID}
|
||||
echoFail "ERROR: ipvs capture running for more than 20 seconds, killing"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
} >> ${logDirectory}/${logName} 2>&1
|
||||
exit 0
|
|
@ -1,194 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import os
|
||||
import getopt
|
||||
import sys
|
||||
import locale
|
||||
import socket
|
||||
import re
|
||||
import httplib
|
||||
import json
|
||||
from qpid.disp import Display, Header, Sorter
|
||||
|
||||
_host = "localhost"
|
||||
_connTimeout = 10
|
||||
_types = ""
|
||||
_limit = 200
|
||||
_increasing = False
|
||||
_sortcol = None
|
||||
pattern = re.compile("^\\d+\\.\\d+\\.\\d+\\.\\d+:\\d+$")
|
||||
|
||||
def Usage ():
|
||||
print "Usage: qpid-queue-count [OPTIONS] [broker-addr]"
|
||||
print
|
||||
print " broker-addr is in the form: [username/password@] hostname | ip-address [:<port>]"
|
||||
print " ex: localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost"
|
||||
print
|
||||
print "General Options:"
|
||||
print " --timeout seconds (10) Maximum time to wait for broker connection"
|
||||
# print " -n [--numeric] Don't resolve names"
|
||||
print
|
||||
print "Display Options:"
|
||||
print " -S [--sort-by] COLNAME Sort by column name"
|
||||
print " -I [--increasing] Sort by increasing value (default = decreasing)"
|
||||
print " -L [--limit] NUM Limit output to NUM rows (default = 200)"
|
||||
print
|
||||
sys.exit (1)
|
||||
|
||||
class RestManager():
|
||||
def __init__(self):
|
||||
self._host = None
|
||||
self._port = 0
|
||||
|
||||
def setPort(self, port):
|
||||
self._port = port
|
||||
|
||||
def setHost(self, host):
|
||||
self._host = host
|
||||
|
||||
def execute(self, service):
|
||||
if (self._port is None):
|
||||
httpConn = httplib.HTTPConnection(self._host)
|
||||
else:
|
||||
httpConn = httplib.HTTPConnection(self._host, self._port)
|
||||
|
||||
if (_connTimeout is not None):
|
||||
httpConn.timeout = _connTimeout
|
||||
|
||||
httpConn.connect()
|
||||
httpConn.request("GET", "/api/v2/" + service)
|
||||
response = httpConn.getresponse()
|
||||
|
||||
if (response.status != 200):
|
||||
print "Unable to post request to server!"
|
||||
print response.reason
|
||||
sys.exit(1)
|
||||
|
||||
return response
|
||||
##
|
||||
## Main Program
|
||||
##
|
||||
try:
|
||||
longOpts = ("top", "numeric", "sort-by=", "limit=", "increasing", "timeout=")
|
||||
(optlist, encArgs) = getopt.gnu_getopt(sys.argv[1:], "bceqS:L:I", longOpts)
|
||||
except:
|
||||
Usage()
|
||||
|
||||
try:
|
||||
encoding = locale.getpreferredencoding()
|
||||
cargs = [a.decode(encoding) for a in encArgs]
|
||||
except:
|
||||
cargs = encArgs
|
||||
|
||||
for opt in optlist:
|
||||
if opt[0] == "--timeout":
|
||||
_connTimeout = int(opt[1])
|
||||
if _connTimeout == 0:
|
||||
_connTimeout = None
|
||||
elif opt[0] == "-n" or opt[0] == "--numeric":
|
||||
_numeric = True
|
||||
elif opt[0] == "-S" or opt[0] == "--sort-by":
|
||||
_sortcol = opt[1]
|
||||
elif opt[0] == "-I" or opt[0] == "--increasing":
|
||||
_increasing = True
|
||||
elif opt[0] == "-L" or opt[0] == "--limit":
|
||||
_limit = int(opt[1])
|
||||
elif len(opt[0]) == 2:
|
||||
char = opt[0][1]
|
||||
if "bcseq".find(char) != -1:
|
||||
_types += char
|
||||
else:
|
||||
Usage()
|
||||
else:
|
||||
Usage()
|
||||
|
||||
if len(_types) == 0:
|
||||
_types='q'
|
||||
|
||||
nargs = len(cargs)
|
||||
rm = RestManager()
|
||||
_user = None
|
||||
_password = None
|
||||
_port = 8180
|
||||
|
||||
if nargs == 1:
|
||||
_broker_addr = cargs[0]
|
||||
_host = _broker_addr
|
||||
|
||||
# check for username
|
||||
if _host.find("@") != -1:
|
||||
tokens = _host.split("@")
|
||||
_user = tokens[0]
|
||||
_host = tokens[1]
|
||||
# check for password
|
||||
if _user.find("/") != -1:
|
||||
tokens = _user.split("/")
|
||||
_user = tokens[0]
|
||||
_password = tokens[1]
|
||||
# check for port
|
||||
if _host.find(":") != -1:
|
||||
tokens = _host.split(":")
|
||||
_host = tokens[0]
|
||||
_port = int(tokens[1])
|
||||
|
||||
try:
|
||||
rm.setHost(_host)
|
||||
rm.setPort(_port)
|
||||
response = rm.execute('queue')
|
||||
|
||||
# evaluate the JSON
|
||||
jsonStr = response.read()
|
||||
jsonObjArray = json.loads(jsonStr)
|
||||
|
||||
# table header
|
||||
heads = []
|
||||
heads.append(Header("queue"))
|
||||
heads.append(Header("msg", Header.KMG))
|
||||
heads.append(Header("bytes", Header.KMG))
|
||||
heads.append(Header("cons", Header.KMG))
|
||||
|
||||
# create rows of queues to display
|
||||
rows = []
|
||||
for staticDict in jsonObjArray:
|
||||
row = []
|
||||
row.append(staticDict.get("name"))
|
||||
statistics = staticDict.get("statistics")
|
||||
row.append(statistics.get("queueDepthMessages"))
|
||||
row.append(statistics.get("queueDepthBytes"))
|
||||
row.append(statistics.get("consumerCount"))
|
||||
rows.append(row)
|
||||
|
||||
# sort the queues if required
|
||||
if _sortcol:
|
||||
sorter = Sorter(heads, rows, _sortcol, _limit, _increasing)
|
||||
dispRows = sorter.getSorted()
|
||||
else:
|
||||
dispRows = rows
|
||||
|
||||
# prepare to build & display the table
|
||||
disp = Display(prefix=" ")
|
||||
disp.formattedTable("Queues", heads, dispRows)
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
except Exception,e:
|
||||
print "Failed: %s - %s" % (e.__class__.__name__, e)
|
||||
sys.exit(1)
|
|
@ -1,355 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import os
|
||||
import getopt
|
||||
import sys
|
||||
import locale
|
||||
import socket
|
||||
import re
|
||||
import httplib
|
||||
import json
|
||||
import time
|
||||
from datetime import datetime
|
||||
from qpid.disp import Display, Header, Sorter
|
||||
|
||||
_host = "localhost"
|
||||
_connTimeout = 10
|
||||
_types = ""
|
||||
_limit = 250
|
||||
_increasing = False
|
||||
_sortcol = None
|
||||
pattern = re.compile("^\\d+\\.\\d+\\.\\d+\\.\\d+:\\d+$")
|
||||
|
||||
def Usage ():
|
||||
print "Usage: qpid-stat [OPTIONS] [broker-addr]"
|
||||
print
|
||||
print " broker-addr is in the form: [username/password@] hostname | ip-address [:<port>]"
|
||||
print " ex: localhost, 10.1.1.7:10000, broker-host:10000, guest/guest@localhost"
|
||||
print
|
||||
print "General Options:"
|
||||
print " --timeout seconds (10) Maximum time to wait for broker connection"
|
||||
# print " -n [--numeric] Don't resolve names"
|
||||
print
|
||||
print "Display Options:"
|
||||
print
|
||||
print " -b Show Brokers"
|
||||
print " -c Show Connections"
|
||||
print " -s Show Sessions"
|
||||
print " -e Show Exchanges"
|
||||
print " -q Show Queues"
|
||||
print
|
||||
print " -S [--sort-by] COLNAME Sort by column name"
|
||||
print " -I [--increasing] Sort by increasing value (default = decreasing)"
|
||||
print " -L [--limit] NUM Limit output to NUM rows (default = 250)"
|
||||
print
|
||||
sys.exit (1)
|
||||
|
||||
class DisplayManager():
|
||||
|
||||
def displayBroker(self, jsonObjArray):
|
||||
disp = Display(prefix=" ")
|
||||
heads = []
|
||||
heads.append(Header('broker'))
|
||||
heads.append(Header('conn', Header.KMG))
|
||||
heads.append(Header('exch', Header.KMG))
|
||||
heads.append(Header('queue', Header.KMG))
|
||||
rows = []
|
||||
for staticDict in jsonObjArray:
|
||||
row = []
|
||||
row.append(staticDict.get("name"))
|
||||
# count the connections, exchanges, and queues
|
||||
# in each virtual host
|
||||
virtualhosts = staticDict.get("virtualhosts")
|
||||
_connectionCount = 0
|
||||
_exchangeCount = 0
|
||||
_queueCount = 0
|
||||
for virtualHost in virtualhosts:
|
||||
statistics = virtualHost.get("statistics")
|
||||
_connectionCount += statistics.get("connectionCount")
|
||||
_exchangeCount += statistics.get("exchangeCount")
|
||||
_queueCount += statistics.get("queueCount")
|
||||
row.append(_connectionCount)
|
||||
row.append(_exchangeCount)
|
||||
row.append(_queueCount)
|
||||
rows.append(row)
|
||||
title = "Brokers"
|
||||
if _sortcol:
|
||||
sorter = Sorter(heads, rows, _sortcol, _limit, _increasing)
|
||||
dispRows = sorter.getSorted()
|
||||
else:
|
||||
dispRows = rows
|
||||
disp.formattedTable(title, heads, dispRows)
|
||||
|
||||
def displayConn(self, jsonObjArray):
|
||||
disp = Display(prefix=" ")
|
||||
heads = []
|
||||
heads.append(Header('client-addr'))
|
||||
heads.append(Header('client-version'))
|
||||
heads.append(Header('auth'))
|
||||
heads.append(Header('last-i/o'))
|
||||
heads.append(Header('msgIn', Header.KMG))
|
||||
heads.append(Header('msgOut', Header.KMG))
|
||||
rows = []
|
||||
for staticDict in jsonObjArray:
|
||||
row = []
|
||||
row.append(staticDict.get("remoteAddress"))
|
||||
row.append(staticDict.get("clientVersion"))
|
||||
row.append(staticDict.get("principal"))
|
||||
statistics = staticDict.get("statistics")
|
||||
lastIOTime = time.gmtime(long(statistics.get("lastIoTime")) / 1000)
|
||||
row.append(time.strftime('%m/%d/%y %H:%M:%S', lastIOTime))
|
||||
row.append(statistics.get("messagesIn"))
|
||||
row.append(statistics.get("messagesOut"))
|
||||
rows.append(row)
|
||||
title = "Connections"
|
||||
if _sortcol:
|
||||
sorter = Sorter(heads, rows, _sortcol, _limit, _increasing)
|
||||
dispRows = sorter.getSorted()
|
||||
else:
|
||||
dispRows = rows
|
||||
disp.formattedTable(title, heads, dispRows)
|
||||
|
||||
def displaySession(self, jsonObjArray):
|
||||
disp = Display(prefix=" ")
|
||||
heads = []
|
||||
heads.append(Header('id'))
|
||||
heads.append(Header('name'))
|
||||
heads.append(Header('consumers'))
|
||||
heads.append(Header('unack-msg', Header.KMG))
|
||||
rows = []
|
||||
for staticDict in jsonObjArray:
|
||||
row = []
|
||||
row.append(staticDict.get("id"))
|
||||
row.append(staticDict.get("name"))
|
||||
statistics = staticDict.get("statistics")
|
||||
row.append(statistics.get("consumerCount"))
|
||||
row.append(statistics.get("unacknowledgedMessages"))
|
||||
rows.append(row)
|
||||
title = "Sessions"
|
||||
if _sortcol:
|
||||
sorter = Sorter(heads, rows, _sortcol, _limit, _increasing)
|
||||
dispRows = sorter.getSorted()
|
||||
else:
|
||||
dispRows = rows
|
||||
disp.formattedTable(title, heads, dispRows)
|
||||
|
||||
def displayExchange(self, jsonObjArray):
|
||||
disp = Display(prefix=" ")
|
||||
heads = []
|
||||
heads.append(Header("exchange"))
|
||||
heads.append(Header("type"))
|
||||
heads.append(Header("dur", Header.Y))
|
||||
heads.append(Header("bind", Header.KMG))
|
||||
heads.append(Header("msgIn", Header.KMG))
|
||||
heads.append(Header("msgDrop", Header.KMG))
|
||||
heads.append(Header("byteIn", Header.KMG))
|
||||
heads.append(Header("byteDrop", Header.KMG))
|
||||
rows = []
|
||||
for staticDict in jsonObjArray:
|
||||
row = []
|
||||
row.append(staticDict.get("name"))
|
||||
row.append(staticDict.get("type"))
|
||||
row.append(staticDict.get("durable"))
|
||||
statistics = staticDict.get("statistics")
|
||||
row.append(statistics.get("bindingCount"))
|
||||
row.append(statistics.get("messagesIn"))
|
||||
row.append(statistics.get("messagesDropped"))
|
||||
row.append(statistics.get("bytesIn"))
|
||||
row.append(statistics.get("bytesDropped"))
|
||||
rows.append(row)
|
||||
title = "Exchanges"
|
||||
if _sortcol:
|
||||
sorter = Sorter(heads, rows, _sortcol, _limit, _increasing)
|
||||
dispRows = sorter.getSorted()
|
||||
else:
|
||||
dispRows = rows
|
||||
disp.formattedTable(title, heads, dispRows)
|
||||
|
||||
def displayQueue(self, jsonObjArray):
|
||||
disp = Display(prefix=" ")
|
||||
heads = []
|
||||
heads.append(Header("queue"))
|
||||
heads.append(Header("dur", Header.Y))
|
||||
heads.append(Header("excl", Header.Y))
|
||||
heads.append(Header("msg", Header.KMG))
|
||||
heads.append(Header("msgIn", Header.KMG))
|
||||
heads.append(Header("msgOut", Header.KMG))
|
||||
heads.append(Header("bytes", Header.KMG))
|
||||
heads.append(Header("bytesIn", Header.KMG))
|
||||
heads.append(Header("bytesOut", Header.KMG))
|
||||
heads.append(Header("cons", Header.KMG))
|
||||
heads.append(Header("bind", Header.KMG))
|
||||
rows = []
|
||||
for staticDict in jsonObjArray:
|
||||
row = []
|
||||
row.append(staticDict.get("name"))
|
||||
row.append(staticDict.get("durable"))
|
||||
row.append(staticDict.get("exclusive"))
|
||||
statistics = staticDict.get("statistics")
|
||||
row.append(statistics.get("queueDepthMessages"))
|
||||
row.append(statistics.get("totalEnqueuedMessages"))
|
||||
row.append(statistics.get("totalDequeuedMessages"))
|
||||
row.append(statistics.get("queueDepthBytes"))
|
||||
row.append(statistics.get("totalEnqueuedBytes"))
|
||||
row.append(statistics.get("totalDequeuedBytes"))
|
||||
row.append(statistics.get("consumerCount"))
|
||||
row.append(statistics.get("bindingCount"))
|
||||
rows.append(row)
|
||||
title = "Queues"
|
||||
if _sortcol:
|
||||
sorter = Sorter(heads, rows, _sortcol, _limit, _increasing)
|
||||
dispRows = sorter.getSorted()
|
||||
else:
|
||||
dispRows = rows
|
||||
disp.formattedTable(title, heads, dispRows)
|
||||
|
||||
def displayMain(self, main, jsonObject):
|
||||
if main == 'b': self.displayBroker(jsonObject)
|
||||
elif main == 'c': self.displayConn(jsonObject)
|
||||
elif main == 's': self.displaySession(jsonObject)
|
||||
elif main == 'e': self.displayExchange(jsonObject)
|
||||
elif main == 'q': self.displayQueue(jsonObject)
|
||||
|
||||
class RestManager():
|
||||
def __init__(self):
|
||||
self._host = None
|
||||
self._port = 0
|
||||
|
||||
def setPort(self, port):
|
||||
self._port = port
|
||||
|
||||
def setHost(self, host):
|
||||
self._host = host
|
||||
|
||||
def execute(self, service):
|
||||
if (self._port is None):
|
||||
httpConn = httplib.HTTPConnection(self._host)
|
||||
else:
|
||||
httpConn = httplib.HTTPConnection(self._host, self._port)
|
||||
|
||||
if (_connTimeout is not None):
|
||||
httpConn.timeout = _connTimeout
|
||||
|
||||
httpConn.connect()
|
||||
httpConn.request("GET", "/api/v2/" + service)
|
||||
response = httpConn.getresponse()
|
||||
|
||||
if (response.status != 200):
|
||||
print "Unable to post request to server!"
|
||||
print response.reason
|
||||
sys.exit(1)
|
||||
|
||||
return response
|
||||
|
||||
##
|
||||
## Main Program
|
||||
##
|
||||
|
||||
try:
|
||||
longOpts = ("top", "numeric", "sort-by=", "limit=", "increasing", "timeout=")
|
||||
(optlist, encArgs) = getopt.gnu_getopt(sys.argv[1:], "bceqsS:L:I", longOpts)
|
||||
except:
|
||||
Usage()
|
||||
|
||||
try:
|
||||
encoding = locale.getpreferredencoding()
|
||||
cargs = [a.decode(encoding) for a in encArgs]
|
||||
except:
|
||||
cargs = encArgs
|
||||
|
||||
for opt in optlist:
|
||||
if opt[0] == "--timeout":
|
||||
_connTimeout = int(opt[1])
|
||||
if _connTimeout == 0:
|
||||
_connTimeout = None
|
||||
elif opt[0] == "-n" or opt[0] == "--numeric":
|
||||
_numeric = True
|
||||
elif opt[0] == "-S" or opt[0] == "--sort-by":
|
||||
_sortcol = opt[1]
|
||||
elif opt[0] == "-I" or opt[0] == "--increasing":
|
||||
_increasing = True
|
||||
elif opt[0] == "-L" or opt[0] == "--limit":
|
||||
_limit = int(opt[1])
|
||||
elif len(opt[0]) == 2:
|
||||
char = opt[0][1]
|
||||
if "bcseqs".find(char) != -1:
|
||||
_types += char
|
||||
else:
|
||||
Usage()
|
||||
else:
|
||||
Usage()
|
||||
|
||||
if len(_types) == 0:
|
||||
Usage()
|
||||
|
||||
nargs = len(cargs)
|
||||
rm = RestManager()
|
||||
_user = None
|
||||
_password = None
|
||||
_port = 8180
|
||||
|
||||
if nargs == 1:
|
||||
_broker_addr = cargs[0]
|
||||
_host = _broker_addr
|
||||
|
||||
# check for username
|
||||
if _host.find("@") != -1:
|
||||
tokens = _host.split("@")
|
||||
_user = tokens[0]
|
||||
_host = tokens[1]
|
||||
# check for password
|
||||
if _user.find("/") != -1:
|
||||
tokens = _user.split("/")
|
||||
_user = tokens[0]
|
||||
_password = tokens[1]
|
||||
# check for port
|
||||
if _host.find(":") != -1:
|
||||
tokens = _host.split(":")
|
||||
_host = tokens[0]
|
||||
_port = int(tokens[1])
|
||||
|
||||
try:
|
||||
rm.setHost(_host)
|
||||
rm.setPort(_port)
|
||||
# determine which REST service we will be utilizing
|
||||
_serviceEndpoint = None
|
||||
if _types[0] == 'b': _serviceEndpoint = "broker"
|
||||
elif _types[0] == 'c': _serviceEndpoint = "connection"
|
||||
elif _types[0] == 's': _serviceEndpoint = "session"
|
||||
elif _types[0] == 'e': _serviceEndpoint = "exchange"
|
||||
elif _types[0] == 'q': _serviceEndpoint = "queue"
|
||||
|
||||
response = rm.execute(_serviceEndpoint)
|
||||
|
||||
# evaluate the JSON
|
||||
jsonStr = response.read()
|
||||
jsonObjArray = json.loads(jsonStr)
|
||||
|
||||
# display construct
|
||||
dm = DisplayManager()
|
||||
dm.displayMain(_types[0], jsonObjArray)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
except Exception,e:
|
||||
print "Failed: %s - %s" % (e.__class__.__name__, e)
|
||||
sys.exit(1)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -111,7 +111,7 @@ if [ $? -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
_QPID_VERSION="0.30"
|
||||
_QPID_VERSION="0.32"
|
||||
RPM_PROJECT="%{_baseline_workspace}/rpms"
|
||||
POSTGRES_INITD="${RPM_PROJECT}/awips2.core/Installer.postgres/scripts/init.d/edex_postgres"
|
||||
QPID_INITD="%{_baseline_workspace}/foss/qpid-java-broker-${_QPID_VERSION}/src/patch/qpid-java-broker-${_QPID_VERSION}/wrapper/qpidd"
|
||||
|
|
|
@ -78,7 +78,7 @@ function lookupRPM()
|
|||
return 0
|
||||
fi
|
||||
if [ "${1}" = "awips2-python-qpid" ]; then
|
||||
export RPM_SPECIFICATION="${python_site__dir}/Installer.qpid"
|
||||
export RPM_SPECIFICATION="${installer_dir}/qpid-python-0.32"
|
||||
return 0
|
||||
fi
|
||||
if [ "${1}" = "awips2-python-scientific" ]; then
|
||||
|
|
|
@ -65,7 +65,7 @@ function buildQPID()
|
|||
fi
|
||||
fi
|
||||
|
||||
cd ${WORKSPACE}/installers/RPMs/qpid-lib-0.30
|
||||
cd ${WORKSPACE}/installers/RPMs/qpid-lib-0.32
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Failed to build the qpid rpms."
|
||||
return 1
|
||||
|
@ -77,16 +77,16 @@ function buildQPID()
|
|||
return 1
|
||||
fi
|
||||
|
||||
#build 0.30
|
||||
#build 0.32
|
||||
export AWIPS_II_TOP_DIR
|
||||
cd ${WORKSPACE}/installers/RPMs/qpid-java-broker-0.30
|
||||
cd ${WORKSPACE}/installers/RPMs/qpid-java-broker-0.32
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Failed to build Qpid Broker v0.30."
|
||||
echo "ERROR: Failed to build Qpid Broker v0.32."
|
||||
return 1
|
||||
fi
|
||||
/bin/bash build.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Failed to build Qpid Broker v0.30."
|
||||
echo "ERROR: Failed to build Qpid Broker v0.32."
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
|
||||
%define _build_arch %(uname -i)
|
||||
%define _python_pkgs_dir "%{_baseline_workspace}/pythonPackages"
|
||||
%define _python_build_loc %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
#
|
||||
# AWIPS II Python qpid Spec File
|
||||
#
|
||||
Name: awips2-python-qpid
|
||||
Summary: AWIPS II Python qpid Distribution
|
||||
Version: 0.30
|
||||
Release: %{_component_version}.%{_component_release}
|
||||
BuildArch: noarch
|
||||
Group: AWIPSII
|
||||
BuildRoot: %{_build_root}
|
||||
BuildArch: noarch
|
||||
URL: N/A
|
||||
License: N/A
|
||||
Distribution: N/A
|
||||
Vendor: Raytheon
|
||||
Packager: Bryan Kowal
|
||||
|
||||
AutoReq: no
|
||||
requires: awips2-python
|
||||
provides: awips2-python-qpid
|
||||
|
||||
%description
|
||||
AWIPS II Python qpid Site-Package
|
||||
|
||||
%prep
|
||||
# Verify That The User Has Specified A BuildRoot.
|
||||
if [ "%{_build_root}" = "" ]
|
||||
then
|
||||
echo "A Build Root has not been specified."
|
||||
echo "Unable To Continue ... Terminating"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf %{_build_root}
|
||||
mkdir -p %{_build_root}
|
||||
if [ -d %{_python_build_loc} ]; then
|
||||
rm -rf %{_python_build_loc}
|
||||
fi
|
||||
mkdir -p %{_python_build_loc}
|
||||
|
||||
%build
|
||||
QPID_SRC_DIR="%{_python_pkgs_dir}/qpid"
|
||||
QPID_TAR="qpid-python-0.30.tar.gz"
|
||||
|
||||
cp -rv ${QPID_SRC_DIR}/${QPID_TAR} \
|
||||
%{_python_build_loc}
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd . > /dev/null
|
||||
cd %{_python_build_loc}
|
||||
tar -xvf ${QPID_TAR}
|
||||
rm -f ${QPID_TAR}
|
||||
popd > /dev/null
|
||||
|
||||
%install
|
||||
QPID_SRC_DIR="%{_python_pkgs_dir}/qpid"
|
||||
QPID_SRC="qpid-python-0.30"
|
||||
QPID_STAT_SCRIPT="qpid-stat"
|
||||
QPID_QUEUE_COUNT_SCRIPT="qpid-queue-count"
|
||||
QPID_MONITOR_SCRIPT="monitor_qpid_host.sh"
|
||||
|
||||
pushd . > /dev/null
|
||||
cd %{_python_build_loc}/${QPID_SRC}
|
||||
mkdir -p %{_build_root}/awips2/python
|
||||
/awips2/python/bin/python setup.py build
|
||||
if [ $? -ne 0 ]; then
|
||||
make install PREFIX=%{_build_root}/awips2/python DATA_DIR=/awips2/python
|
||||
fi
|
||||
/awips2/python/bin/python setup.py install \
|
||||
--root=%{_build_root} \
|
||||
--prefix=/awips2/python
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
popd > /dev/null
|
||||
|
||||
# Copy the stats script to bin
|
||||
cp -v ${QPID_SRC_DIR}/bin/${QPID_STAT_SCRIPT} \
|
||||
%{_build_root}/awips2/python/bin
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy the queue-counting script to bin
|
||||
cp -v ${QPID_SRC_DIR}/bin/${QPID_QUEUE_COUNT_SCRIPT} \
|
||||
%{_build_root}/awips2/python/bin
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy the monitoring script to bin
|
||||
cp -v ${QPID_SRC_DIR}/bin/${QPID_MONITOR_SCRIPT} \
|
||||
%{_build_root}/awips2/python/bin
|
||||
|
||||
%preun
|
||||
|
||||
%postun
|
||||
|
||||
%clean
|
||||
rm -rf ${RPM_BUILD_ROOT}
|
||||
rm -rf %{_python_build_loc}
|
||||
|
||||
%files
|
||||
%defattr(644,awips,fxalpha,755)
|
||||
%dir /awips2/python/lib/python2.7/site-packages
|
||||
/awips2/python/lib/python2.7/site-packages/*
|
||||
%defattr(755,awips,fxalpha,755)
|
||||
%dir /awips2/python/bin
|
||||
/awips2/python/bin/*
|
Loading…
Add table
Reference in a new issue