JMX MBean Liberty 서버 연결 설정
JMX(Java™ Management Extensions) MBean Liberty 서버 연결을 설정하기 위해 Jython 기반 스크립트를 사용할 수 있습니다.
시작하기 전에
프로시저
- 환경을 설정하십시오.
필요한 파일은 liberty_home/clients/jython에 위치됩니다.
- lib/restConnector.py 파일을 jython_home/Lib에 복사하십시오.
- liberty_home/clients에서 restConnector.jar에 대한 클래스 경로를 설정하십시오.
set CLASSPATH=%CLASSPATH%;c:\wlp\clients\restConnector.jar
- 유틸리티를 실행하십시오. 예제 1: connector.connect(host,port,user,password)를 사용하여 단순 연결 가져오기
from restConnector import JMXRESTConnector JMXRESTConnector.trustStore = "c:/key.jks" JMXRESTConnector.trustStorePassword = "Liberty" connector = JMXRESTConnector() connector.connect("foo.bar.com",9443,"theUser","thePassword") mconnection = connector.getMBeanServerConnection() # mconnection.invoke(...) connector.disconnect()
예제 2: 사용자 제공 특성이 있는 connector.connect(host,port,map)를 사용하여 고급 연결 가져오기import java import javax import jarray import com.ibm.websphere.jmx.connector.rest import com.ibm.ws.jmx.connector.client.rest map=java.util.HashMap() map.put("jmx.remote.provider.pkgs","com.ibm.ws.jmx.connector.client") map.put(javax.management.remote.JMXConnector.CREDENTIALS,jarray.array(["theUser","thePassword"],java.lang.String)) map.put(com.ibm.ws.jmx.connector.client.rest.ClientProvider.READ_TIMEOUT,2*60*1000) map.put(com.ibm.websphere.jmx.connector.rest.ConnectorSettings.DISABLE_HOSTNAME_VERIFICATION, True) connector = JMXRESTConnector() connector.connect("foo.bar.com",9443,map) mconnection = connector.getMBeanServerConnection() # mconnection.invoke(...) connector.disconnect()
예제 3: 알림 리스너 등록import java import javax from restConnector import JMXRESTConnector from restConnector import BaseNotificationListener class SampleNotificationListener(BaseNotificationListener): def __init__(self): pass def handleNotification(self,notification,handback): print "Notification received:" print " Source: " + notification.getSource().toString() print " Type: " + notification.getType() print " Message: " + notification.getMessage() # main starts here JMXRESTConnector.trustStore = "c:/key.jks" JMXRESTConnector.trustStorePassword = "Liberty" connector=JMXRESTConnector() connector.connect("foo.bar.com",9443,"theUser","thePassword") mconnection=connector.getMBeanServerConnection() listener=SampleNotificationListener() handback=java.lang.Object() notifier1=javax.management.ObjectName("web:name=Notifier1") mconnection.addNotificationListener(notifier1,listener,None,handback)
- JMXRESTConnector.trustStore
- SSL 키 파일이 저장되는 위치에 대한 경로를 설정합니다.
- JMXRESTConnector.trustStorePassword
- 키의 비밀번호를 설정합니다.
- JMXRESTConnector.connect(host,port,user,password)
- 서버에 대한 커넥터를 작성합니다.
- JMXRESTConnector.connect(host,port,map)
- 사용자 특성에 대한 커넥터를 작성합니다.
- JMXRESTConnector.getMBeanServerConnection
- MBean 서버와의 연결을 가져옵니다.
- JMXRESTConnector.disconnect()
- 연결을 닫습니다.
다음에 수행할 작업
MBean 서버와의 연결이 설정되면, invoke(...) 메소드를 사용하여 MBean 서버를 호출할 수 있습니다.
참고: Jython 스크립트의 라이브러리는 Liberty
Repository에서 다운로드할 수 있습니다.
상위 주제: 수동으로 Liberty 관리


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-libcore-mp&topic=twlp_admin_serverconnection
파일 이름: twlp_admin_serverconnection.html