weblogic的健康状态仅仅通过进程和状态是无法判断的需要通过去控制台去查看部署项目的实例健康状态。所以需要监控所有weblogic部署实例的状态
#!/usr/bin/pyhton
USER = {"username": "weblogic", "password": "xxxxx", "url": "t3://10.178.x.x:7001"}
def format_wr(data):
all_data = []
for i in data.split("\n"):
if i:
ci_list = i.split()
if "-r-" in ci_list[0]:
pass
else:
all_data.append(" ".join(ci_list[1:]))
return all_data
connect(USER["username"], USER["password"], USER["url"])
status={'STATE_ACTIVE':1,'STATE_PREPARED':2}
cd("AppDeployments")
apps = format_wr(ls())
domainRuntime()
cd('domainRuntime:/AppRuntimeStateRuntime/AppRuntimeStateRuntime')
for app in apps:
currentState = cmo.getCurrentState(app,'AdminServer')
print {app:status[currentState]}```