Weblogic簡(jiǎn)介
Oracle WebLogic Server 是一個(gè)統(tǒng)一的可擴(kuò)展平臺(tái),專(zhuān)用于開(kāi)發(fā)、部署和運(yùn)行 Java 應(yīng)用等適用于本地環(huán)境和云環(huán)境的企業(yè)應(yīng)用。它提供了一種強(qiáng)健、成熟和可擴(kuò)展的 Java Enterprise Edition (EE) 和 Jakarta EE 實(shí)施方式。
背景說(shuō)明
近期客戶要求對(duì)現(xiàn)有系統(tǒng)的Weblogic中間件DOMAIN域(Server,JDBC)配置信息進(jìn)行采集分析。以便于對(duì)DOMAIN域(Server,JDBC)配置進(jìn)行規(guī)范化、統(tǒng)一化配置管理,以及協(xié)助問(wèn)題定位等。
采集指標(biāo)
AdminServer名稱(chēng)
控制臺(tái)地址上下文
域的版本
域的路徑
Server名稱(chēng)
監(jiān)聽(tīng)地址
監(jiān)聽(tīng)端口
SSL監(jiān)聽(tīng)端口
是否啟用IIOP (1:啟用,0:未啟用)
粘滯線程最長(zhǎng)時(shí)間
...
數(shù)據(jù)源名稱(chēng)
數(shù)據(jù)源的目標(biāo)服務(wù)器
數(shù)據(jù)源的URL
數(shù)據(jù)源屬性配置
初始容量
最大容量
最小容量
開(kāi)啟保留時(shí)測(cè)試連接 (1:啟用,0:未啟用)
測(cè)試頻率(秒數(shù))
收縮頻率(秒數(shù))
非活動(dòng)連接超時(shí)秒數(shù)
...
采集方案
WebLogic 腳本工具(WLST)是一個(gè)命令行腳本環(huán)境,您可以用它來(lái)創(chuàng)建、管理和監(jiān)控 WebLogic 域。它基于Java腳本解釋器,Jython。除了支持標(biāo)準(zhǔn)的 Jython 功能(如本地變量、條件變量和流量控制語(yǔ)句)外,WLST 還提供一組特定于 WebLogic 服務(wù)器的腳本功能(命令)。您可以按照 Jython 語(yǔ)言語(yǔ)法擴(kuò)展 WebLogic 腳本語(yǔ)言以滿足您的需求。
接下來(lái),我們將用一組腳本來(lái)進(jìn)行說(shuō)明:
1. weblogic_getparams.sh(實(shí)現(xiàn)采集總體框架)
2. weblogic_getparams.py(實(shí)現(xiàn)Weblogic指標(biāo)數(shù)據(jù)采集)
3. auth_info.cfg(配置Weblogic控制臺(tái)登錄授權(quán)信息)
4. 采集結(jié)果文件:
result_wls_params.txt
result_jdbc_params.txt
實(shí)現(xiàn)腳本
#!/bin/bash
##. $HOME/.bash_profile
## Check parameters
if [ $# -eq 2 ]
then
## The Weblogic Product install directory
WLS_HOME=$1
## The Weblogic Console authorization info
AUTH_FILE=$2
else
echo "###########################################################################################################"
echo "usage: sh $0 WLS_HOME AUTH_FILE"
echo "eg1: sh $0 /weblogic/Oracle/Middleware/wlserver_10.3 auth_info.cfg"
echo
echo "function description:"
echo "Get weblogic server config parameters"
echo "The "WLS_HOME" : The Weblogic Product install directory (grep "WL_HOME=" setDomainEnv.sh)."
echo "The "AUTH_FILE" : The Weblogic Console authorization file (eg: /weblogic/shell/maintain/auth_info.cfg)."
echo
echo "Platform :All Linux Based Platform and HP-UX"
echo "version: 1.0"
echo "author: [email protected]"
echo "create: 2021-12-20."
echo "###########################################################################################################"
exit
fi
## Define variable
WORK_HOME=$(dirname $(readlink -f "$0"))
PYTHON_SCRIPT="${WORK_HOME}/weblogic_getparams.py"
WLS_PARAMS_FILE="${WORK_HOME}/result_wls_params.txt"
JDBC_PARAMS_FILE="${WORK_HOME}/result_jdbc_params.txt"
if [ -f "${WLS_HOME}" ]
then
echo [`date +%Y-%m-%d %H:%M:%S`]" The WLS_HOME [${WLS_HOME}] is non-exist, exit !"
exit
fi
echo [`date +%Y-%m-%d %H:%M:%S`]" ======================[BEGIN]====================================================="
# Use wlst.sh to execute pyhton shell
${WLS_HOME}/common/bin/wlst.sh ${PYTHON_SCRIPT} ${AUTH_FILE} ${WLS_PARAMS_FILE} ${JDBC_PARAMS_FILE}
echo [`date +%Y-%m-%d %H:%M:%S`]" ======================[END]======================================================="
## Get weblogic server config parameters
# encoding:utf-8
AUTH_FILE = sys.argv[1]
WLS_PARAMS_FILE = sys.argv[2]
JDBC_PARAMS_FILE = sys.argv[3]
focfg = open(AUTH_FILE, "rb")
fowlstxt = open(WLS_PARAMS_FILE, "wb")
fojdbctxt = open(JDBC_PARAMS_FILE, "wb")
########################################################
##獲取WLS相關(guān)配置信息
def getWLSparams():
print >>fowlstxt, "%-s" % ("========================================================================================================================")
##監(jiān)聽(tīng)地址
AdminServerName = cmo.getAdminServerName()
##AdminServer名稱(chēng)
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,AdminServerName,"AdminServerName",cmo.getAdminServerName())
##AdminServer協(xié)議
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,AdminServerName,"AdministrationProtocol",cmo.getAdministrationProtocol())
##控制臺(tái)地址上下文
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,AdminServerName,"ConsoleContextPath",cmo.getConsoleContextPath())
##域的版本
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,AdminServerName,"DomainVersion",cmo.getDomainVersion())
##域的名稱(chēng)
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,AdminServerName,"DomainName",cmo.getName())
##域的路徑
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,AdminServerName,"DomainHome",cmo.getRootDirectory())
servers=cmo.getServers()
for server in servers:
print >>fowlstxt, "%-s" % ("----------------------------------------------------------------------------------------------------")
##Server名稱(chēng)
serverName=server.getName()
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"ServerName",server.getName())
##監(jiān)聽(tīng)地址
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"ListenAddress",server.getListenAddress())
##啟用監(jiān)聽(tīng)端口
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"ListenPortEnabled",server.isListenPortEnabled())
##監(jiān)聽(tīng)端口
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"ListenPort",server.getListenPort())
##啟用SSL監(jiān)聽(tīng)端口
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"SSLListenPortEnabled",server.getSSL().isEnabled())
##SSL監(jiān)聽(tīng)端口
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"SSLListenPort",server.getSSL().getListenPort())
##啟用IIOP
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"IIOPEnabled",server.isIIOPEnabled())
##啟用本地IO
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"NativeIOEnabled",server.isNativeIOEnabled())
##默認(rèn)隊(duì)列中可以用作套接字讀取器的執(zhí)行線程的百分比
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"ThreadPoolPercentSocketReaders",server.getThreadPoolPercentSocketReaders())
##最大打開(kāi)套接字?jǐn)?shù)
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"MaxOpenSockCount",server.getMaxOpenSockCount())
##粘滯線程最長(zhǎng)時(shí)間
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"StuckThreadMaxTime",server.getStuckThreadMaxTime())
##粘滯線程計(jì)時(shí)器間隔
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"StuckThreadTimerInterval",server.getStuckThreadTimerInterval())
##應(yīng)該允許的積壓的新TCP連接請(qǐng)求的數(shù)量
print >>fowlstxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,serverName,"AcceptBacklog",server.getAcceptBacklog())
##獲取JDBC相關(guān)配置信息
def getJDBCparams():
dataSources=cmo.getJDBCSystemResources()
for dataSource in dataSources:
print >>fojdbctxt, "%-s" % ("----------------------------------------------------------------------------------------------------")
##數(shù)據(jù)源名稱(chēng)
jdbcName=dataSource.getName()
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"JdbcName",jdbcName)
##數(shù)據(jù)源配置文件路徑
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"SourcePath",dataSource.getSourcePath())
##數(shù)據(jù)源的目標(biāo)服務(wù)器
targets=dataSource.getTargets()
for target in targets:
print >>fojdbctxt, "%-25s- %-20s- %-40s: %s" % (adminurl,jdbcName,"Targets",target.getName())
cd("/JDBCSystemResources/"+jdbcName+"/JDBCResource/"+jdbcName+"/JDBCDriverParams/"+jdbcName)
##數(shù)據(jù)庫(kù)的URL
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"Url",cmo.getUrl())
##驅(qū)動(dòng)程序類(lèi)名稱(chēng)
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"DriverName",cmo.getDriverName())
###數(shù)據(jù)源屬性配置
cd("/JDBCSystemResources/"+jdbcName+"/JDBCResource/"+jdbcName+"/JDBCDriverParams/"+jdbcName+"/Properties/"+jdbcName)
properties=cmo.getProperties()
for proper in properties:
print >>fojdbctxt, "%-25s- %-20s- %-40s: %s=%-s" % (adminurl,jdbcName,"Properties",proper.getName(),proper.getValue())
cd("/JDBCSystemResources/"+jdbcName+"/JDBCResource/"+jdbcName+"/JDBCConnectionPoolParams/"+jdbcName)
##初始容量
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"InitialCapacity",cmo.getInitialCapacity())
##最大容量
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"MaxCapacity",cmo.getMaxCapacity())
##最小容量
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"MinCapacity",cmo.getMinCapacity())
##語(yǔ)句高速緩存類(lèi)型
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"StatementCacheType",cmo.getStatementCacheType())
##語(yǔ)句高速緩存大小
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"StatementCacheSize",cmo.getStatementCacheSize())
##保留時(shí)測(cè)試連接
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"TestConnectionsOnReserve",cmo.isTestConnectionsOnReserve())
##測(cè)試頻率(秒數(shù))
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"TestFrequencySeconds",cmo.getTestFrequencySeconds())
##測(cè)試表表名
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"TestTableName",cmo.getTestTableName())
##信任空閑池連接的(秒數(shù))
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"SecondsToTrustAnIdlePoolConnection",cmo.getSecondsToTrustAnIdlePoolConnection())
##收縮頻率(秒數(shù))
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"ShrinkFrequencySeconds",cmo.getShrinkFrequencySeconds())
##重試創(chuàng)建連接的頻率(秒數(shù))
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"ConnectionCreationRetryFrequencySeconds",cmo.getConnectionCreationRetryFrequencySeconds())
##登錄延遲
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"LoginDelaySeconds",cmo.getLoginDelaySeconds())
##非活動(dòng)連接超時(shí)秒數(shù)
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"InactiveConnectionTimeoutSeconds",cmo.getInactiveConnectionTimeoutSeconds())
##最大等待連接數(shù)
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"HighestNumWaiters",cmo.getHighestNumWaiters())
##連接保留超時(shí)(秒數(shù))
print >>fojdbctxt, "%-25s- %-20s- %-40s: %-s" % (adminurl,jdbcName,"ConnectionReserveTimeoutSeconds",cmo.getConnectionReserveTimeoutSeconds())
############################################################
for authinfo in focfg:
autharray = authinfo.split(",")
if len(autharray) < 3:
continue
###cfgfile = autharray[0].strip()
###keyfile = autharray[1].strip()
###adminurl = autharray[2].strip()
###connect(userConfigFile=cfgfile,userKeyFile=keyfile,url=adminurl)
UserName = autharray[0].strip()
PassWord = autharray[1].strip()
AdminUrl = autharray[2].strip()
connect(UserName,PassWord,AdminUrl)
##獲取WLS相關(guān)配置信息
getWLSparams()
##獲取JDBC相關(guān)配置信息
getJDBCparams()
disconnect()
focfg.close()
fowlstxt.close()
fojdbctxt.close()
exit()
weblogic,password,t3://10.243.*.*:7011
weblogic,password,t3://10.243.*.*:7012
weblogic,password,t3://10.243.*.*:7013
注:控制臺(tái)登錄授權(quán)信息也可以通過(guò)wlst自帶的storeUserConfig()方法進(jìn)行加密處理,具體使用方法可百度搜索查看。
4. 采集結(jié)果樣例
4.1 result_wls_params.txt
格式說(shuō)明:以冒號(hào)”:”分割
URL:ServerName:屬性名稱(chēng):屬性值
4.2 result_jdbc_params.txt
格式說(shuō)明:以冒號(hào)”:”分割
URL:JDBC名稱(chēng):屬性名稱(chēng):屬性值
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/129676.html
閱讀 1356·2023-01-11 13:20
閱讀 1707·2023-01-11 13:20
閱讀 1215·2023-01-11 13:20
閱讀 1906·2023-01-11 13:20
閱讀 4165·2023-01-11 13:20
閱讀 2757·2023-01-11 13:20
閱讀 1402·2023-01-11 13:20
閱讀 3671·2023-01-11 13:20