pythonlinuxweblogicweblogic12cwlst

How to get IP address of weblogic managed server using WLST


I have a weblogic admin server and managed server. I am able to fetch the managed server name , its heap utilization etc from admin server using wlst. Now i would like to know if there is any way we can get the IP address of managed server using wlst scripts.

WLST script iam using

from datetime import datetime
from java.util import Date
from java.text import SimpleDateFormat
import os
import smtplib
import time
from java.io import File
from java.io import FileOutputStream
connect('weblogic','weblogic','t3://192.168.30.100:5011')
servers = domainRuntimeService.getServerRuntimes();

for server in servers:
        free    = int(server.getJVMRuntime().getHeapFreeCurrent())/(1024*1024)
        freePct = int(server.getJVMRuntime().getHeapFreePercent())
        #current = int(server.getJVMRuntime().getHeapSizeCurrent())/(1024*1024)
        #max     = int(server.getJVMRuntime().getHeapSizeMax())/(1024*1024)
        #print (server.getName(),current,free,max,freePct)
        print (server.getName(),freePct)
        print (server.getName(),free)
        heapfreepct = "/usr/local/bin/aws cloudwatch put-metric-data --metric-name 'Weblogic_heap_percent' --value '"+str(freePct)+"' --unit 'Percent' --namespace System/weblogic --dimensions InstanceId=$instanceid,weblogicInstance='"+str(server.getName())+"';"
        os.system(heapfreepct)
        heapsizefree = "/usr/local/bin/aws cloudwatch put-metric-data --metric-name 'Weblogic_heap_free' --value '"+str(free)+"' --unit 'Megabytes' --namespace System/weblogic --dimensions InstanceId=$instanceid,weblogicInstance='"+str(server.getName())+"';"
        os.system(heapsizefree)
disconnect()
exit()

Solution

  • Try this :

    server.getListenAddress()