0

I'm trying to create a script which will display all JVM status.

so far, i've created a script which basically calls serverStatus.sh and is then run from different hosts to get status of each JVM from different machines. then the script puts it in a text file in a shared file system. which is i know really sucks. i'm just wondering if there is a way like wlst.sh does the checking.

Example output:

  • Server1 machine1 : RUNNING
  • Server2 machine1 : RUNNING
  • Server3 machine2 : RUNNING
  • Server4 machine2 : RUNNING
  • Server5 machine5 : STOPPED
Roo-Gi
  • 1
  • 1
  • 2

1 Answers1

3

If you are in an ND environment, you can use a wsadmin script to check status of Server MBean (see Server MBean - Javadoc).

Here is a code snippet that may be helpful.

nodes=AdminConfig.getid('/Node:/').splitlines()
nodenames=[ AdminConfig.showAttribute(node,'name') for node in nodes ]
j2eeServerTuples=[]
for nodename in nodenames:
    serversString="/Node:%s/Server:/" % (nodename)
    servers=AdminConfig.getid(serversString).splitlines()
    for server in servers:
        if AdminConfig.showAttribute(server,'serverType') in ['APPLICATION_SERVER','DEPLOYMENT_MANAGER','NODE_AGENT'] :
            j2eeServerTuples.append( (nodename, AdminConfig.showAttribute(server,'name')) )

for (nodename,servername) in j2eeServerTuples:
    mBeanString = 'WebSphere:*,name=%s,type=Server,j2eeType=J2EEServer,node=%s' % (servername, nodename)
    serverMBean = AdminControl.queryNames(mBeanString)
    if (len(serverMBean) == 0):
        (state, pid) = ("UNREACHABLE", "-----")
    else:
        (state, pid) = (AdminControl.getAttribute(serverMBean,'state'), AdminControl.getAttribute(serverMBean,'pid'))

    print "%20s: %-30s => %15s : %s" % ( nodename, servername, state, pid)

Some tips of the above script.

  1. The script talks to the dmgr, so it must be running.
  2. wsadmin has its overhead, so better run this in a long-running loop than calling wsadmin multiple times.
dbreaux
  • 4,982
  • 1
  • 25
  • 64
Ek C.
  • 103
  • 1
  • 3
  • please correct me if i'm wrong, i think it only shows the server status of the servers in the same machine as the dmgr. i still need to duplicate the script and run it to the other node/machines am i right? – Roo-Gi Apr 17 '19 at 08:53
  • The script shows the status of all servers within the cell. The first for loop populates the list of (nodename, servername) to be used by the Server MBean in the second for loop. You don't need to duplicate it to managed nodes. – Ek C. Apr 19 '19 at 10:20
  • @EkC. above script is helpful. I also need host name of the JVM/server where it's running to automate few things. Any idea how to get that by passing a node or server name either in above context or a generic AdminTask command? – cnu Oct 04 '19 at 16:36
  • I can use AdminTask.listServerPorts and other commands but trying to see if there is a direct command without parsing the data. – cnu Oct 04 '19 at 16:56