Date Created: Thu 07-Feb-2008

Related Document Categories:

Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/


    How to show the status of all the members of a WebSphere cluster using JACL

    This example shoes how to list all the servers in a WebSphere cluster using a JACL script and to log the results to a file.

    show_server_status.jacl

    #------------------------------------------------------------------------------------------
    # This script shows the status of cluster and its member servers.
    # This script generates the serverstatus.log file with date, time and status information.
    # Pass one or more cluster names as command line argument to this script.
    # Usage: wsadmin.sh -f ccs_show_server_status.jacl clusterName1 clusterName2 ............
    #------------------------------------------------------------------------------------------
    if {$argc > 0} {
    set fp [open "serverstatus.log" a+]
    puts $fp "------------------------------------------"
    set datetime [clock format [clock seconds] -format {%b. %d, %Y %I:%M:%S %p}]
    puts $fp "$datetime - Log file to show the status of the cluster and servers"
    set i 0
    while {$i < $argc} {
    #set clusterName [$props getProperty sib.cluster.name]
    set clusterName [lindex $argv $i]
    puts "$datetime - ClusterName is: $clusterName"
    puts $fp "$datetime - ClusterName is: $clusterName"
    set clusterId [$AdminConfig getid /ServerCluster:$clusterName/]
    if {[llength $clusterId] == 1} {
    set datetime [clock format [clock seconds] -format {%b. %d, %Y %I:%M:%S %p}]
    puts "$datetime - Cluster '$clusterName' exists."
    puts $fp "$datetime - Cluster '$clusterName' exists."
    set clusterObject [$AdminControl completeObjectName type=Cluster,name=$clusterName,*]
    set datetime [clock format [clock seconds] -format {%b. %d, %Y %I:%M:%S %p}]
    set clusterStatus [$AdminControl getAttribute $clusterObject state]
    puts $fp "$datetime - $clusterName is $clusterStatus"
    puts "$datetime - $clusterName is $clusterStatus"
    set clusterMembers [$AdminConfig list ClusterMember $clusterId]
    foreach m_id $clusterMembers {
    set currentServerName [$AdminConfig showAttribute $m_id memberName]
    set currentNodeName [$AdminConfig showAttribute $m_id nodeName]
    set currentServerObject [$AdminControl completeObjectName type=Server,node=$currentNodeName,process=$currentServerName,*]
    if {[llength $currentServerObject] > 0} {
    set currentServerStatus [$AdminControl getAttribute $currentServerObject state]
    set datetime [clock format [clock seconds] -format {%b. %d, %Y %I:%M:%S %p}]
    puts "$datetime - $currentServerName is $currentServerStatus"
    puts $fp "$datetime - $currentServerName is $currentServerStatus"
    } else {
    set datetime [clock format [clock seconds] -format {%b. %d, %Y %I:%M:%S %p}]
    puts "$datetime - $currentServerName is either STOPPED or in the process of STARTING"
    puts $fp "$datetime - $currentServerName is either STOPPED or in the process of STARTING"
    }
    }
    } else {
    set datetime [clock format [clock seconds] -format {%b. %d, %Y %I:%M:%S %p}]
    puts "$datetime - Cluster '$clusterName' doesnot exist."
    puts $fp "$datetime - Cluster '$clusterName' doesnot exist."
    }
    unset clusterName
    unset clusterId
    incr i
    }
    puts $fp "------------------------------------------"
    close $fp
    } else {
    puts "Please supply cluster name command line argument."
    puts "Usage: wsadmin.sh -f ccs_show_server_status.jacl clusterName1 clusterName2 .........."
    }

    Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/


Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.


Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Other Categories