- How to know All Queue Connection Factory "QCF" on Cell.
- Show all custom properties if exit
- Add new custom property for all QCF (option)
Output example:
clustername |qcfName |jndiName |Cache|MisTr|ConUs|Manager |host |port|channel |trTp |msg |Quies|poll|rInt|ConPol|namResProp |type |value |desc |requi| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ CLUSTER1 |None |None |None |None |None |None |None |None|None |None |None |None |None|None|None |None |None |None |None |None | CLUSTER2 |MQD1 |jms/MQD1 |false|true |false|MQD1 |MQD1 |2828|titi.SVRCONN |CLIENT|true |true |5000|5000|true |None |None |None |None |None | CLUSTER3 |MQD2 |jms/MQD2 |false|true |false|MQD2 |MQD2 |2828|toto.SVRCONN |CLIENT|true |true |5000|5000|true |test |java.lang.String |test |Just for test |false|
Shell Code:(with mail option)
#! /bin/ksh webSphereProfilesPath="/usr/IBM/WebSphere/AppServer/profiles" #profil=$1 PROG_NAME=$(basename $0) serverName=`uname -n` logFile="none" logLevel="3" custom="none" save="none" function help { lstProfiles=`df | grep profiles | awk '{printf $7"\n"}' | awk -F/ '{printf $NF" "}'` printf "\nUsage: ${PROG_NAME} [ -m \"user1@probtp.com,user2@probtp.com,etc\"-f logfile_name -l logLevel -p profileName]\n" printf "\t-m Option to send mail to user\n" printf "\t-f enable log in file\n" printf "\t-l log level {0 = Debug, 3=Error}\n" printf "\t-p {profileName} = one of ${lstProfiles}\n" printf "\t-c Add new Custom property: \"nameCustom,typeCustom,valueCustom,descCustom,ReqCustom\n\"" printf "\t\t example : \"MAPNAMESTYLE,java.lang.String,STANDARD,MAPNAMESTYLE_is_set_to_false_to_have_the_standard_JMS_format,false\"\n" } while getopts c:p:f:l:m:h OPTION do case ${OPTION} in f) logFile=${OPTARG};; l) logLevel=${OPTARG};; m) sendMail=${OPTARG};; p) profil=${OPTARG};; c) custom=${OPTARG};; s) save="true";; h) help exit 2;; esac done if [ -e "/tmp/mail.tmp" ]; then printf "with options:\n\tlog File=>${logFile}\n \tlog Level=>${logLevel}\n \tcustom property=> ${custom}\n\tand save option => ${save} \n \n" > /tmp/mail.tmp fi if [[ "$profil" == "" ]];then help | tee -a /tmp/mail.tmp profil=`df | grep profiles | awk '{printf $7"\n"}' | awk -F/ '{printf $NF" "}' | awk '{printf $1}'` #http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html # write in Red: echo "\033[31mLaunch by default whith option -p ${profil}\033[m" printf "Launch by default whith option -p ${profil}\n\n" >> /tmp/mail.tmp fi if [ -e "${logFile}" ]; then echo "Starting ....." > ${logFile} fi cd ${webSphereProfilesPath}/${profil}/bin/ ./wsadmin.sh -lang jython -f /probtp_outils/was/jython/ListeQueueConnectionFactory.jy ${logFile} ${logLevel} ${custom} ${save}| grep -v "WASX7" | grep -v "sys-package-mgr" | tee -a /tmp/mail.tmp if [[ "$sendMail" != "" ]];then if [[ "$logFile" != "none" ]];then zip -T ${logFile}.zip ${logFile} uuencode ${logFile}.zip ${logFile}.joint.zip > ${logFile}.joint.zip echo "\n" >> /tmp/mail.tmp cat ${logFile}.joint.zip >> /tmp/mail.tmp rm -f ${logFile}.zip rm -f ${logFile}.joint.zip fi mailx -r "${serverName}" -s "[${serverName}] ${PROG_NAME} DMGR:${profil} " "${sendMail}" < /tmp/mail.tmp fi
Jython Code :
# extrait le séparateur de ligne # /usr/IBM/WebSphere/AppServer/profiles/node01Val/bin # ./wsadmin.sh -lang jython -f /probtp_outils/was/jython/ListeQueueConnectionFactory.jy import time sys.path.append("/probtp_outils/was/jython/") #import tools #import java.lang.System as sys execfile('/probtp_outils/was/jython/tools.py') lineSeparator = java.lang.System.getProperty('line.separator') scriptname = "ListeDataSource.jy" if len(sys.argv) != 4: log = Logging() log.print(log.ERROR,"Missing 3 arguments") log.print(log.ERROR," - first: logPathName (must be none") log.print(log.ERROR," - second: log level " + log.VALUELEVEL) log.print(log.ERROR," - third ->: custom properties like 'MAPNAMESTYLE' 'java.lang.String' 'STANDARD' 'MAPNAMESTYLE is set to false to have the standard JMS format' 'false'") log.print(log.ERROR,"example:" + scriptname + " \"\" 3") sys.exit(0) else: pathLog = sys.argv[0] levelLog = sys.argv[1] #Logging For Debug log = Logging(pathLog,levelLog) log.setLevel(levelLog) log.setFileName(pathLog) log.setClassname2Log("[ListQCF]") custom = sys.argv[2] if custom != "none": log.print(log.DEBUG,"custom: " + str(custom)) custom = custom.split(",") log.print(log.DEBUG,"lcustom: " + str(custom)) nameCustom = custom[0] typeCustom = custom[1] typeValue = custom[2] descCustom = custom[3] reqCustom = custom[4] else: nameCustom = "none" typeCustom = "none" typeValue = "none" descCustom = "none" reqCustom = "none" save = sys.argv[3] log.print(log.INFO,"logs Path Option: " + pathLog) log.print(log.INFO,"logs level: " + levelLog) log.print(log.INFO,"name Custom: " + nameCustom) log.print(log.INFO,"type Custom: " + typeCustom) log.print(log.INFO,"type Value: " + typeValue) log.print(log.INFO,"desc Custom: " + descCustom) log.print(log.INFO,"reqCustom: " + reqCustom) log.print(log.DEBUG,"Get Cells List:") log.print(log.DEBUG,"cells = AdminConfig.list('Cell').split(lineSeparator)") def getobjectCustomProperties(object): logGetobjectCustomProperties = copy.deepcopy(log) logGetobjectCustomProperties.setClassname2Log("[getobjectCustomProperties]") logGetobjectCustomProperties.print(logGetobjectCustomProperties.DEBUG,"AdminConfig.showAttribute('" + object +"','propertySet')") return AdminConfig.showAttribute(object,"propertySet") def getCustomProperties(object): logGetCustomProperties = copy.deepcopy(log) logGetCustomProperties.setClassname2Log("[getCustomProperties]") propertiesName = {} # propertiesSet1 = getobjectCustomProperties(object) # log.print(log.DEBUG,"AdminConfig.showAttribute('" + object +"','propertySet')") # if propertiesSet1 is not None: propertiesSet = object.split(lineSeparator) for propertySet in propertiesSet: logGetCustomProperties.print(logGetCustomProperties.DEBUG,"CQF Ressource property: " + propertySet) logGetCustomProperties.print(logGetCustomProperties.DEBUG,"AdminConfig.showAttribute('" + propertySet +"','resourceProperties').split()") resProperties = AdminConfig.showAttribute(propertySet,"resourceProperties").split() for resProperty in resProperties: valueproperty={} strResProperty = resProperty.replace('[','').replace(']','') logGetCustomProperties.print(logGetCustomProperties.DEBUG,"resProperty.replace=" + strResProperty) nameResProperty = AdminConfig.showAttribute(strResProperty,"name") valueproperty['name'] = nameResProperty type = AdminConfig.showAttribute(strResProperty,"type") valueproperty['type'] = type value = AdminConfig.showAttribute(strResProperty,"value") valueproperty['value'] = value description = AdminConfig.showAttribute(strResProperty,"description") if description is not None: description = description[:20] + "..." valueproperty['description'] = description required = AdminConfig.showAttribute(strResProperty,"required") valueproperty['required'] = required logGetCustomProperties.print(logGetCustomProperties.DEBUG,"CQF Ressource property: " + nameResProperty) propertiesName[nameResProperty] = valueproperty return propertiesName def printQcf(object): logPrintQcf = copy.deepcopy(log) logPrintQcf.setClassname2Log("[printQcf]") qcfName = object["qcfName"] jndiName = object["jndiName"] manageCachedHandles = object["manageCachedHandles"] logMissingTransactionContext = object["logMissingTransactionContext"] diagnoseConnectionUsage = object["diagnoseConnectionUsage"] XAEnabled = object["XAEnabled"] queueManager = object["queueManager"] host = object["host"] port = object["port"] channel = object["channel"] transportType = object["transportType"] msgRetention = object["msgRetention"] failIfQuiesce = object["failIfQuiesce"] pollingInterval = object["pollingInterval"] rescanInterval = object["rescanInterval"] useConnectionPooling = object["useConnectionPooling"] customProperties = object["propertiesName"] logPrintQcf.print(logPrintQcf.DEBUG,"customProperties= object[\"propertiesName\"]=" + str(customProperties)) if customProperties == "None": nameResProperty = "None" type = "None" value = "None" description = "None" required = "None" print "%-16s|%-8s|%-12s|%-5s|%-5s|%-5s|%-8s|%-8s|%-4s|%-17s|%-6s|%-5s|%-5s|%-4s|%-4s|%-6s|%-12s|%-17s|%-8s|%-23s|%-5s|" % (clustername,qcfName,jndiName,manageCachedHandles,logMissingTransactionContext,diagnoseConnectionUsage,queueManager,host,port,channel,transportType,msgRetention,failIfQuiesce,pollingInterval,rescanInterval,useConnectionPooling,nameResProperty,type,value,description,required) else: for keyCustomProperty in customProperties.keys(): nameResProperty = customProperties[keyCustomProperty]["name"] type = customProperties[keyCustomProperty]["type"] value = customProperties[keyCustomProperty]["value"] description = customProperties[keyCustomProperty]["description"] required = customProperties[keyCustomProperty]["required"] print "%-16s|%-8s|%-12s|%-5s|%-5s|%-5s|%-8s|%-8s|%-4s|%-17s|%-6s|%-5s|%-5s|%-4s|%-4s|%-6s|%-12s|%-17s|%-8s|%-23s|%-5s|" % (clustername,qcfName,jndiName,manageCachedHandles,logMissingTransactionContext,diagnoseConnectionUsage,queueManager,host,port,channel,transportType,msgRetention,failIfQuiesce,pollingInterval,rescanInterval,useConnectionPooling,nameResProperty,type,value,description,required) def addProperty(oneQCF,propSet): logAddProperty = copy.deepcopy(log) logAddProperty.setClassname2Log("[addProperty]") #Création de la Proprieté manquante logAddProperty.print(logAddProperty.DEBUG,"AdminConfig.create('J2EEResourcePropertySet', "+ oneQCF+", []") if propSet is None: logAddProperty.print(logAddProperty.DEBUG,"J2EEResourcePropertySet creating ...") propSet = AdminConfig.create('J2EEResourcePropertySet', oneQCF, []) else: propSet=propSet.replace('[','').replace(']','') logAddProperty.print(logAddProperty.DEBUG,"J2EEResourcePropertySet exist: ") logAddProperty.print(logAddProperty.DEBUG,"\t" + str(propSet)) lstPropValues=[['name',nameCustom],['type',typeCustom],['value',typeValue],['description',descCustom],['required',reqCustom]] #[['name', 'java.naming.security.principal'], ['value', jcapsUserID]] logAddProperty.print(logAddProperty.DEBUG,"AdminConfig.create('J2EEResourceProperty', '"+ str(propSet) + "', '" + str(lstPropValues) +"')") AdminConfig.create('J2EEResourceProperty', propSet, lstPropValues) if save != "none": logAddProperty.print(logAddProperty.INFO,"saving ...)") #AdminConfig.save() else: logAddProperty.print(logAddProperty.INFO," NOT SAVED !!!!!!") return propSet cells = AdminConfig.list('Cell').split(lineSeparator) for cell in cells: nameCell = AdminConfig.showAttribute(cell,"name") #Logging For Debug log.print(log.DEBUG,"Cell Name: " + nameCell) log.print(log.DEBUG,"Get Cluster List:") log.print(log.DEBUG,"lstClusters = AdminConfig.list('ServerCluster'," + cell + ").split(lineSeparator)") # En-têtes: print "\033[1m%-16s|%-8s|%-12s|%-5s|%-5s|%-5s|%-8s|%-8s|%-4s|%-17s|%-6s|%-5s|%-5s|%-4s|%-4s|%-6s|%-12s|%-17s|%-8s|%-23s|%-5s|\033[0;0m" % ("clustername","qcfName","jndiName","Cache","MisTr","ConUs","Manager","host","port","channel","trTp","msg","Quies","poll","rInt","ConPol","namResProp","type","value","desc","requi") print "-" * 204 lstClusters = AdminConfig.list('ServerCluster',cell).split(lineSeparator) for oneCluster in lstClusters: clustername = AdminConfig.showAttribute(oneCluster,"name") #Logging For Debug log.print(log.DEBUG,"Cluster Name: " + clustername) log.print(log.DEBUG,"Get QCF List:") log.print(log.DEBUG,"llstQCF = AdminConfig.list('MQQueueConnectionFactory'," + oneCluster + ")") lstQCF = AdminConfig.list('MQQueueConnectionFactory',oneCluster) if lstQCF != "": lstQCF = lstQCF.split(lineSeparator) for oneQCF in lstQCF: tabQcfValue={} #Inistaialisation du tableau de valeur de la QCF tabQcfValue["qcfName"] = AdminConfig.showAttribute(oneQCF,"name") #Logging For Debug log.print(log.DEBUG,"QCF: " + oneQCF) log.print(log.INFO,"CQF Name: " + tabQcfValue["qcfName"] + "; " + oneQCF) tabQcfValue["jndiName"] = AdminConfig.showAttribute(oneQCF,"jndiName") log.print(log.INFO,"jndiName: " + tabQcfValue["jndiName"] ) tabQcfValue["manageCachedHandles"] = AdminConfig.showAttribute(oneQCF,"manageCachedHandles") tabQcfValue["logMissingTransactionContext"] = AdminConfig.showAttribute(oneQCF,"logMissingTransactionContext") tabQcfValue["diagnoseConnectionUsage"] = AdminConfig.showAttribute(oneQCF,"diagnoseConnectionUsage") tabQcfValue["XAEnabled"] = AdminConfig.showAttribute(oneQCF,"XAEnabled") tabQcfValue["queueManager"] = AdminConfig.showAttribute(oneQCF,"queueManager") tabQcfValue["host"] = AdminConfig.showAttribute(oneQCF,"host") tabQcfValue["port"] = AdminConfig.showAttribute(oneQCF,"port") tabQcfValue["channel"] = AdminConfig.showAttribute(oneQCF,"channel") tabQcfValue["transportType"] = AdminConfig.showAttribute(oneQCF,"transportType") tabQcfValue["msgRetention"] = AdminConfig.showAttribute(oneQCF,"msgRetention") tabQcfValue["failIfQuiesce"] = AdminConfig.showAttribute(oneQCF,"failIfQuiesce") tabQcfValue["pollingInterval"] = AdminConfig.showAttribute(oneQCF,"pollingInterval") tabQcfValue["rescanInterval"] = AdminConfig.showAttribute(oneQCF,"rescanInterval") tabQcfValue["useConnectionPooling"] = AdminConfig.showAttribute(oneQCF,"useConnectionPooling") #propertiesSet=printCustomProperties(oneQCF) propertiesSet=getobjectCustomProperties(oneQCF) log.print(log.DEBUG,"propertiesSet: " + str(propertiesSet)) if propertiesSet is None: if nameCustom != "none": newPropSet = addProperty(oneQCF,None) tabQcfValue["propertiesName"] = getCustomProperties(newPropSet) else: tabQcfValue["propertiesName"] = "None" else: propertiesName=getCustomProperties(propertiesSet) log.print(log.DEBUG,"propertiesName: " + str(propertiesName)) if nameCustom != "none": if nameCustom in propertiesName.keys(): log.print(log.INFO,"propertiesName Allready exist") tabQcfValue["propertiesName"] = propertiesName else: addProperty(oneQCF,propertiesSet) tabQcfValue["propertiesName"] = getCustomProperties(propertiesSet) else: tabQcfValue["propertiesName"] = getCustomProperties(propertiesSet) printQcf(tabQcfValue) else: tabQcfValue={} tabQcfValue["qcfName"] = "None" tabQcfValue["jndiName"] = "None" tabQcfValue["manageCachedHandles"] = "None" tabQcfValue["logMissingTransactionContext"] = "None" tabQcfValue["diagnoseConnectionUsage"] = "None" tabQcfValue["XAEnabled"] = "None" tabQcfValue["queueManager"] = "None" tabQcfValue["host"] = "None" tabQcfValue["port"] = "None" tabQcfValue["channel"] = "None" tabQcfValue["transportType"] = "None" tabQcfValue["msgRetention"] = "None" tabQcfValue["failIfQuiesce"] = "None" tabQcfValue["pollingInterval"] = "None" tabQcfValue["rescanInterval"] = "None" tabQcfValue["useConnectionPooling"] = "None" tabQcfValue["propertiesName"] = "None" printQcf(tabQcfValue)
Aucun commentaire:
Enregistrer un commentaire