2014-04-26 5 views
1

으로 캡처합니다. 아래 출력을 변수로 캡처해야합니다. serverRuntime 또는 domainRuntime() 트리에 도착하여 상태를 얻을 수 있다는 것을 알고 있습니다. 하지만 아래에서 일해야합니다. 당신은 서버 런타임 MBean의 getState() 방법을 사용할 필요가WLST는 상태 ('ms1')의 출력을 변수

wls:/owb/serverConfig> print state('Server1') 
Current state of 'Server1' : RUNNING 
None 

wls:/owb/serverConfig> x=state('Server1') 
Current state of 'Server1' : RUNNING 

wls:/owb/serverConfig> print x 
None 

답변

2

:

wls:/owb/serverConfig> state('Server1') 
Current state of 'Server1' : RUNNING 

나는 두 가지 방법을 시도했다. wlst 런타임 트리로 이동하거나 조회 방법을 사용하여 서버 런타임 MBean을 얻을 수 있습니다.

샘플 :

domainRuntime() 
slrBean = cmo.lookupServerLifeCycleRuntime('Server1') 
status = slrBean.getState() 
print 'Status of Managed Server is '+status 

도 WLST 공식 문서에서 Getting Runtime Information 참조하십시오.

+0

매력처럼 작동하고 무엇을하고 난 다음 오류가 발생합니다 : WLS를) 추적 (가장 안쪽 마지막) : 파일 "", 줄 1,? AttributeError : lookupServerLifecycleRuntime – SSA

+2

이것은 정답이지만 사이클에는 대문자 C가 있어야합니다. – SSA

+0

lookupServerLifeCycleRuntime에 많은 코드가있는 고정 코드입니다. @ user3460652 –

1

Dianyuan Wang이 (가) 나와 동일한 질문을 던졌습니다. 다음은 문제를 해결하기위한 단계입니다. 1. redirect, stopRedirect 명령을 사용하여 state 명령의 출력을 캡처하십시오. 2. 검색 기능에서 Python 정규 표현식을 사용하여 원하는 서버 출력을 추출하십시오.

코드는이 블록 후 원하는 논리를 적용 할 수 있습니다 여기에 지금

  fileName='/tmp/myserver_state.txt' 
      redirect(fileName) 
      state(server_nm,'Server') 
      stopRedirect() 
      f = open(fileName) 
      try: 
        for line in f.readlines(): 
          if re.search('Current state',line): 
            status[server_nm]=line 
      except: 
        continue 

입니다.

건배 !!/OWB/domainRuntime> slrBean = cmo.lookupServerLifecycleRuntime ('owb001' HTH 여기

+0

예, 이것이 유일한 방법이라고 생각합니다. 파일에 쓰지 않고도? – SSA

0

은 내가 사용하고 나는 그것을 시도

cd("/ServerRuntimes/ms1") 
    state=cmo.getState() 
    print state