Wednesday, September 28, 2011

Jython Script to check the Status of listener ports on all servers of cluster

lineSeparator = java.lang.System.getProperty('line.separator')

cId = AdminConfig.getid("/ServerCluster:"+ clusterName +"/" )
cList = AdminConfig.list("ClusterMember", cId ).split(lineSeparator)
for sId in cList:
server = AdminConfig.showAttribute(sId, "memberName" )
node = AdminConfig.showAttribute(sId, "nodeName" )
cell = AdminControl.getCell()

s1 = AdminControl.completeObjectName('cell='+ cell +',node='+node +',name='+ server +',type=Server,*')
if len(s1) > 0:
print server + " state is started"
print server + " is down"

print "Server " + server + " has the following Listener Ports"
lPorts = AdminControl.queryNames('type=ListenerPort,cell='+ cell+',node='+ node +',process='+ server +',*')
lPortsArray = lPorts.split(lineSeparator)
for lPort in lPortsArray:
lpcfgId = AdminControl.getConfigId(lPort)
lpName = AdminConfig.showAttribute(lpcfgId, "name")
lpstate = AdminControl.getAttribute(lPort, 'started')
if lpstate == 'true':
print lpName + " is started "
else :
print lpName + " is stopped "

print ""

1 comment:

  1. JACL script to check status of one msg listener for a cluster and to start the msg listener in-case it is in stopped state...

    puts ""
    puts "================================="
    puts ""
    set cellname
    set cluname
    set msglstnrname

    set clusterObject [$AdminConfig getid /Cell:$cellname/ServerCluster:$cluname/]
    set memberlist [$AdminConfig showAttribute $clusterObject members]
    set members [lindex $memberlist 0]
    puts "Cluster $cluname has [llength $members] members"
    foreach member $members {
    set memname [$AdminConfig showAttribute $member memberName]
    set memnode [$AdminConfig showAttribute $member nodeName]
    set memberObject [$AdminControl completeObjectName name=$memname,type=Server,cell=$cellname,node=$memnode,process=$memname*]
    set memberObject [$AdminControl completeObjectName type=Server,name=$memname,*]

    if {[llength $memberObject] > 0} {
    set memstatus [$AdminControl getAttribute $memberObject state]
    set memstatus [$AdminControl getAttribute $memberObject state]
    puts ""
    puts "AppServer $memname on $memnode: is already $memstatus"
    set msglstnrobj [$AdminControl completeObjectName name=$msglstnrname,type=ListenerPort,cell=$cellname,node=$memnode,process=$memname,*]
    set msglstnrstatus1 [$AdminControl getAttribute $msglstnrobj started]

    if {$msglstnrstatus1 == "true"} {
    puts "Message Listener Status: $msglstnrname on $memname is already started"
    } else {
    puts "Message Listener Status: $msglstnrname on $memname is stopped ... starting"
    $AdminControl invoke $msglstnrobj start
    after 10000
    set msglstnrstatus2 [$AdminControl getAttribute $msglstnrobj started]
    if {$msglstnrstatus2 == "true"} {
    puts "Message Listener Status: $msglstnrname on $memname is started"
    } else {
    puts "Message Listener Status: Tried to start $msglstnrname on $memname, NOT STARTED"

    } else {
    puts ""
    puts "AppServer $memname on $memnode: is either STOPPED/STARTING"