java weblogic 每分钟检查一次服务器状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14018043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
weblogic check server status every minute
提问by siva
When I use the following command
当我使用以下命令时
java weblogic.Admin -url %URL% -username %WLS_USER% -password %WLS_PW% GET -pretty -mbean "%DOMAIN_NAME%:Name=%ADMINSERVER_SERVERNAME%,Type=Server" -property ListenPort
to check the status of the server every minute, the CPU usage shoots upto 70% for just running this command and my application requires me to check the status every minute using this command, which is undesirable.
为了每分钟检查服务器的状态,仅运行此命令的 CPU 使用率高达 70%,我的应用程序要求我使用此命令每分钟检查一次状态,这是不可取的。
How to check the health of the a weblogic server instance every minute with min CPU/time using command line util so that I could invoke from script.
如何使用命令行工具以最少的 CPU/时间每分钟检查一次 weblogic 服务器实例的运行状况,以便我可以从脚本中调用。
回答by sweetfa
The following WLST script can be used to check the status of each of the servers
以下 WLST 脚本可用于检查每个服务器的状态
#!/usr/bin/python
#
# Script to return the status of each of the servers
#
class StatusResult:
def __init__(self,serverName,serverStatus):
self.name = serverName
self.status = serverStatus
connect('username','password','t3://servername')
redirect('/dev/null','false')
nmStatus = 'Stopped'
if nm() == 1:
nmStatus = 'RUNNING'
statuses = [ StatusResult('NodeManager',nmStatus) ]
# Get the list of managed servers from AdminServer
for server in ['AdminServer', 'soa_server1', 'osb_server1', 'bam_server1']:
statuses.append(StatusResult(server,nmServerStatus(server)))
stopRedirect()
for result in statuses:
print result.name + ": " + result.status
disconnect()
To invoke the script
调用脚本
. ${WL_HOME}/server/bin/setWLSEnv.sh
${MW_HOME}/oracle_common/common/bin/wlst.sh statusscript
Alternatively you can use something as simple as a http check on the port of the server to see if it responds. This will put minimal load on the server. For example you could use the nagios plugin check_http to check the status of a particular server.
或者,您可以使用简单的方法,例如对服务器端口进行 http 检查以查看它是否响应。这将使服务器的负载最小。例如,您可以使用 nagios 插件 check_http 来检查特定服务器的状态。
check_http -I serveraddr -p serverport -e 404
check_http -I serveraddr -p serversslport --ssl -e 404