Link to home
Start Free TrialLog in
Avatar of sweety_745
sweety_745Flag for United States of America

asked on

wsadmin script

Hi all,


Could any body help me in the below request


1)	We are trying to Automate the Adapter Polling failure, For this we need to get a script to run the doing the following task’s using wsadmin.
Script 1
Run the wsadmin.sh
1)	AdminControl.queryNames("*:type=J2CMessageEndpoint,*")
Send the result of the above to a text file in readable format.
script 2
2)	Need to read Variable from text file
objectName = AdminControl.queryNames("*$NEEDToReadFromInPutText$,*")
AdminControl.invoke(objectName, 'getStatus')
If Status Result is 1 , go to next Value  in the InputText
If the status Result is 2, run the below cmd:
AdminControl.invoke(objectName, 'resume')
AdminControl.invoke(objectName, 'getStatus')
If Status Result is 2 for second time, run the Script3
And continue to next value in the text file.
After Completion of all the values in the text,  It will publish the result for each value in the input text  file to a new outputText file with current System time in the name of the text file.
Script3
Where Script 3 will be recycling that app.
I can work on this script



InputTextFile
Values in the Text File will be as below might contain 50 values:
*:name=BPEContainer_qnode_server1#bpecontainer.jar#ProcessContainerMDB_J2CMessageEndpoint*
*: name=HTM_PredefinedTasks_V700_qnode_server1App#HTM_PredefinedTasks_V700_qnode_server1*



Thanks in advance
Avatar of HonorGod
HonorGod
Flag of United States of America image

Sweety:

Q: Why do you want to write the MBean names to a file?
     There is no guarantee that these MBean names wouldn't change after a resource is recycled.

Q: What, exactly, do you mean by a "readable format"?

Q: Why do you want to read the MBean names from a file?

Q: When you say that the input file may contain 50 values, do you mean that you have upwards of 50 Messaging Engines defined in your environment?
Avatar of sweety_745

ASKER

1) We have more than 50 Services deployed and we are trying to get the "J2CMessageEndpoint" of all those applications.  We are not using the whole MBean value returned by query names.  we are using only the part which will be always constant.  which is similar to below. This part of the name will always same even after recycle.

  ("*:name=FFAdapterTest3App#FFAdapterTest3FFAdapterExport#FFAdapterTest3_J2CMessageEndpoint,*")

2) When we run the cmd AdminControl.queryNames("*:type=J2CMessageEndpoint,*")   it is giving the output. we want that output to be captured to a text file by separating them where we have "\r\n " in the result to new line, so that it will be easy to read those values


3) We want pass the values from a text file. So, the script will be running only to specific applications, not for all the services which are deployed. By reading from the text file, we can pre define what are the services; we need to run the script against.
   Note:  We are not use the text file from the script1 as it is. We capture the Script1 out put text file and edit it and give that text file as input to script 2.

4) We have around 50 applications which are using flat file adapter and intermittently it will stop pooling for some reason. SO we are trying to monitor those. Not the WPS ME's MBean. I just sent those as example earlier.
What is the output of the following script:

wsadmin -lang jython -c "print AdminControl.getConfigId( AdminControl.queryNames('*:type=J2CMessageEndpoint,*').splitlines()[ 0 ] )"

Open in new window


I'm interested in what kind of configuration type corresponds to the MessageEndpoint bean.

Thanks
When I run the exact script you mentioned, it is not returning me any value. But I captured the output of the below cmd’s and attaching it to thread

AdminControl.queryNames("*:type=J2CMessageEndpoint,*")
  Check the “dev-J2CMessageEndpoint-OutPut.txt”


Print AdminApp.list()
Check the “dev-AdminAppList.txt”
dev-J2CMessageEndpoint-OutPut.txt
dev-AdminAppList.txt
Each of the MBeans appear to have the following attribute names. I've included the values from the first MBean in the output.

              name = AutoProcessModApp#AutoProcessMod#AutoProcessMod_J2CMessageEndpoint
           process = WPSDEV2.AppTarget.dev12-DEV02-Node01.0
    ActivationSpec = sca/AutoProcessMod/ActivationSpec
          platform = dynamicproxy
              node = dev12-DEV02-Node01
   J2EEApplication = AutoProcessModApp
          j2eeType = JCAMessageEndpoint
        J2EEServer = WPSDEV2.AppTarget.dev12-DEV02-Node01.0
            Server = WPSDEV2.AppTarget.dev12-DEV02-Node01.0
           version = 7.0.0.19
J2CResourceAdapter = Platform Messaging Component SPI Resource Adapter
              type = J2CMessageEndpoint
   mbeanIdentifier = cells/dev10-DEV02-cell01/clusters/WPSDEV2.AppTarget/resources.xml#J2CResourceAdapter_1271775552245#AutoProcessModApp#AutoProcessMod#AutoProcessMod_J2CMessageEndpoint
              cell = dev10-DEV02-cell01
 MessageDrivenBean = AutoProcessModApp#AutoProcessMod#AutoProcessMod
              spec = 1.0

Open in new window


Which of these values do you want saved in the file?
I would like to save below values.
name = AutoProcessModApp#AutoProcessMod#AutoProcessMod_J2CMessageEndpoint
J2EEApplication = AutoProcessModApp
For Script2 I can use the value of “name” and for Script 3 I can use the value of  “J2EEApplication” for recycling the App if Script 2 didn’t able to solve the stale
What command line parameters do you want / need to specify on script #1?

Option #1 - no parameters - simply redirect output of the script to a file:

wsadmin -lang jython -f myBeans.py >myOutputFile.txt

Open in new window


Option #2 - no parameters - hard coded output file within script:

wsadmin -lang jython -f myBeans.py

Open in new window


A simple example if which might be:

meBeans.py
fileName   = 'meBeans.txt'
attributes = 'name,J2EEApplication'.split( ',' )

if __name__ in [ '__main__', 'main' ] :
    fh = open( fileName, 'w' )
    for me in AdminControl.queryNames("*:type=J2CMessageEndpoint,*").splitlines() :
        bean = {}
        for attr in attributes :
            bean[ attr ] = AdminControl.getAttribute( me, attr )
        fh.write( `bean` )
    fh.close()
else :
    print '\nError: script must be executed, not imported.\n'
    print 'Usage: wsadmin -f %s' % __name__

Open in new window




Option #3 - required command line parameter = output filename:

wsadmin -lang jython -f myBeans.py myOutputFile.txt

Open in new window


Option #4 - required command line parameter = input config/property file identifying output filename:

wsadmin -lang jython -f myBeans.py myInputFile.ini

Open in new window

I tried the below:
./wsadmin.sh -lang jython -f myBeans.py >myOutputFile.txt
But this is what I see in the outputfile

WASX7209I: Connected to process "dmgr" on node dev10-DEV02-CellManager using SOAP connector;  The type of process is: DeploymentManager
WASX7017E: Exception received while running file "myBeans.py"; exception information: javax.management.AttributeNotFoundException: getAttribute failed: ModelMBeanAttributeInfo not found for name
The script I provided had the output file hard coded.
That's why it was under the part labelled "Option #2 - no parameters - hard coded output file within script"

AttributeNotFoundException - interesting.

If you use an interactive wsadmin session, i.e.,

--------------------------------------------------------------------------------------------------------------
wsadmin -lang jython
--------------------------------------------------------------------------------------------------------------
bean = AdminControl.queryNames("*:type=J2CMessageEndpoint,*").splitlines()[ 0 ]
print 'name:', AdminControl.getAttribute( bean, 'name' )
print 'J2EE:', AdminControl.getAttribute( bean, 'J2EEApplication' )
--------------------------------------------------------------------------------------------------------------

Do you get the same Exception on the second print statement?
This is what i got:

WASX7209I: Connected to process "dmgr" on node dev10-DEV-CellManager using SOAP connector;  The type of process is: DeploymentManager
WASX7031I: For help, enter: "print Help.help()"
wsadmin>bean = AdminControl.queryNames("*:type=J2CMessageEndpoint,*").splitlines()[ 0 ]
wsadmin>bean
'WebSphere:name=ARINT6_BbSap_PrMedApp#ARINT6_BbSap_PrMed#ARINT6_BbSap_PrMed_J2CMessageEndpoint,process=DEV0_GOLD.AppTarget.dev11-Node01.0,ActivationSpec=sca/ARINT6_BbSap_PrMed/ActivationSpec,platform=dynamicproxy,node=dev11-Node01,J2EEApplication=ARINT6_BbSap_PrMedApp,j2eeType=JCAMessageEndpoint,J2EEServer=DEV0_GOLD.AppTarget.dev11-Node01.0,Server=DEV0_GOLD.AppTarget.dev11-Node01.0,version=7.0.0.19,J2CResourceAdapter=Platform Messaging Component SPI Resource Adapter,type=J2CMessageEndpoint,mbeanIdentifier=cells/dev10-DEV-cell01/clusters/DEV0_GOLD.AppTarget/resources.xml#J2CResourceAdapter_1296743291683#ARINT6_BbSap_PrMedApp#ARINT6_BbSap_PrMed#ARINT6_BbSap_PrMed_J2CMessageEndpoint,cell=dev10-DEV-cell01,MessageDrivenBean=ARINT6_BbSap_PrMedApp#ARINT6_BbSap_PrMed#ARINT6_BbSap_PrMed,spec=1.0'

wsadmin>print 'name:', AdminControl.getAttribute( bean, 'name' )
name:WASX7015E: Exception running command: "'name:', AdminControl.getAttribute( bean, 'name' )"; exception information:
 javax.management.AttributeNotFoundException: getAttribute failed: ModelMBeanAttributeInfo not found for name

wsadmin>print 'J2EE:', AdminControl.getAttribute( bean, 'J2EEApplication' )
 J2EE:WASX7015E: Exception running command: "'J2EE:', AdminControl.getAttribute( bean, 'J2EEApplication' )"; exception information:
 javax.management.AttributeNotFoundException: getAttribute failed: ModelMBeanAttributeInfo not found for J2EEApplication
i think this it the correct error we are getting:

wsadmin>objectName = AdminControl.queryNames("*:type=J2CMessageEndpoint,*").splitlines()
wsadmin>print 'name:', AdminControl.getAttribute( objectName, 'name' )
name:WASX7015E: Exception running command: "'name:', AdminControl.getAttribute( objectName, 'name' )"; exception information:
 com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  File "<input>", line 1, in ?
TypeError: getAttribute(): 1st arg can't be coerced to String
The second is wrong because AdminControl.queryNames("*:type=J2CMessageEndpoint,*").splitlines() returns a list of strings.
That's why the 1st has [ 0 ] at the end, to obtain the 1st list element.

Let me work on this and get back to you.
Hi HonorGod,
    Did you got chance to look into the script i need help with ?
Try this:

fileName   = 'meBeans.txt'
attributes = 'name,J2EEApplication'

#-------------------------------------------------------------------------------
# Name: MBnameAsDict
# Role: Return a dictionary of name/value portions of an MBean name
# Note: Exception handler requires sys module
#-------------------------------------------------------------------------------
def MBnameAsDict( beanName ) :
    'MBnameAsDict( beanName ) - Return a dictionary of the beans name/value parts.'
    funName = 'MBnameAsDict'           # Name of this function
    domain  = 'WebSphere:'             # MBean name prefix
    result  = {}                       # Result is a dictionary

    #---------------------------------------------------------------------------
    # Error message for unexpected exceptions
    #---------------------------------------------------------------------------
    ERRMSG  = '%(funName)s: Unexpected exception.\n'
    ERRMSG += '  Exception  type: %(Type)s\n'
    ERRMSG += '  Exception value: %(value)s'

    #---------------------------------------------------------------------------
    # Warning message for "bad" MBean names
    #---------------------------------------------------------------------------
    WARNING  = '%(funName)s:\n'
    WARNING += "Warning: Specified MBean name doesn't start with "
    WARNING += '"%(domain)s" and is ignored.\n  MBean name: "%(beanName)s"'

    try :
        #-----------------------------------------------------------------------
        # Verify that we are working with a WebSphere MBean
        #-----------------------------------------------------------------------
        if beanName.startswith( domain ) :
            #-------------------------------------------------------------------
            # The rest of MBean name only has comma separated name=value pairs
            #-------------------------------------------------------------------
            for field in beanName[ len( domain ): ].split( ',' ) :
                name, value = field.split( '=', 1 )
                result[ name ] = value
        else :
            print WARNING % locals()
    except :
        Type, value  = sys.exc_info()[ :2 ]
        print ERRMSG % locals()
    return result

#-------------------------------------------------------------------------------
# Name: anonymous
# Role: This where script execution appears to begin
#-------------------------------------------------------------------------------
if __name__ in [ '__main__', 'main' ] :
    attr = [ a.strip() for a in attributes.split( ',' ) ]
    fh = open( fileName, 'w' )
    for me in AdminControl.queryNames("*:type=J2CMessageEndpoint,*").splitlines() :
        ok, result, d = 1, {}, MBnameAsDict( me )
        for a in attr :
            if d.has_key( a ) :
                result[ a ] = d[ a ]
            else :
                ok = 0
                print 'Required attribute "%s" missing from bean: %s' % ( a, me )
        if ok :
            fh.write( `result` )
    fh.close()
else :
    print '\nError: script must be executed, not imported.\n'
    print 'Usage: wsadmin -f %s' % __name__

Open in new window

Hi HonorGod,
Wow... Script1 looks good, getting the expected result.
PFA of meBean.txt
is it possible for getting it more user-friendly ?


For the Script 2 and Script3
PFA for the input file.


for Script 2, we will get the name from the input file.
try for 3 times to updating the status.
if it fails for 3 times,
 

Script 3 will restart that particular app and send and email or save the result to the file  for verifying the list of the app's it restarted for the week, using the script.

Thanks
meBeans.txt
Script2-Input.txt
What does PFA mean?

The output format for the file is whatever you want it to be.
What would you prefer?
Sorry, I mean Please Find Attachment (PFA).
 Can you help me with Script 2 and Script 3.
I would prefer output of script 1 needs to be easy for reading and which we can directly use it for input of script 2 and script 3,
just by manually removing the WPS system services from  the output text of the Script1 and pass it to other scripts
Ah, now I understand.  Thanks for the clarification.  PFA was not an acronym with which I was familiar.

One reason that the file is hard to read is that there is supposed to be a newline between the }{ characters, so each line should have looked something like this:

{'name': 'BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint', 'J2EEApplication': 'BPCECollector_qnode_server1'}

Is that better, or would you prefer each line to look this this?

name=BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint,J2EEApplication=BPCECollector_qnode_server1

Next question:
- using that 2nd format, what do you get if you look for the MBean using this code?

bName = 'name=BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint,J2EEApplication=BPCECollector_qnode_server1'

bean = AdminControl.queryNames( bName + ',*' )

Does the "bean" variable contain an MBean object name, or is it an empty string?

The reason I'm asking is that I'm not 100% certain that the queryNames() call will actually find the bean in question given those values (i.e., name and J2EEApplication).

Does that make sense?
Please check the below and let me know, if didn't answer your question:

wsadmin>AdminControl.queryNames('*:type=J2CMessageEndpoint,*').splitlines()[ 0 ]
'WebSphere:name=BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint,process=server1,ActivationSpec=eis/BPCCEIConsumerActivation
Spec,platform=dynamicproxy,node=qnode,J2EEApplication=BPCECollector_qnode_server1,j2eeType=JCAMessageEndpoint,J2EEServer=server1,Server=server1,versio
n=7.0.0.21,J2CResourceAdapter=SIB JMS Resource Adapter,type=J2CMessageEndpoint,mbeanIdentifier=cells/qcell/nodes/qnode/servers/server1/resources.xml#J
2CResourceAdapter_1266047668543#BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint,cell=qcell,MessageDrivenBean=BPCECollector_
qnode_server1#collector.jar#EventConsumer,spec=1.0'


wsadmin>objectName=AdminControl.queryNames("*:name=BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint,*")

wsadmin>print objectName
WebSphere:name=BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint,process=server1,ActivationSpec=eis/BPCCEIConsumerActivationS
pec,platform=dynamicproxy,node=qnode,J2EEApplication=BPCECollector_qnode_server1,j2eeType=JCAMessageEndpoint,J2EEServer=server1,Server=server1,version
=7.0.0.21,J2CResourceAdapter=SIB JMS Resource Adapter,type=J2CMessageEndpoint,mbeanIdentifier=cells/qcell/nodes/qnode/servers/server1/resources.xml#J2
CResourceAdapter_1266047668543#BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint,cell=qcell,MessageDrivenBean=BPCECollector_q
node_server1#collector.jar#EventConsumer,spec=1.0

When the object was working as expected, it will give the below result

wsadmin>AdminControl.invoke(objectName, 'getStatus')
'1'

wsadmin>AdminControl.invoke(objectName, 'pause')
''

When the oject was not working as expected it will give the result as below


wsadmin>AdminControl.invoke(objectName, 'getStatus')
'2'

If the result is 2, we need to run the below cmd:

wsadmin>AdminControl.invoke(objectName, 'resume')
''
wsadmin>AdminControl.invoke(objectName, 'getStatus')
'1'
wsadmin>
That helps.

Your sample shows that if we have the output of script 1 be of the form:

name=<something>,J2EEApplication=<something>

or even

name=<something>,J2EEApplication=<something>,*

then script #2 could read this file, and use it to determine if the specified object instances exist.

If this would be acceptable for you, then try this as a possible solution for scrpt #1

fileName   = 'meBeans.txt'
attributes = 'name,J2EEApplication'

#-------------------------------------------------------------------------------
# Name: MBnameAsDict
# Role: Return a dictionary of name/value portions of an MBean name
# Note: Exception handler requires sys module
#-------------------------------------------------------------------------------
def MBnameAsDict( beanName ) :
    'MBnameAsDict( beanName ) - Return a dictionary of the beans name/value parts.'
    funName = 'MBnameAsDict'           # Name of this function
    domain  = 'WebSphere:'             # MBean name prefix
    result  = {}                       # Result is a dictionary

    #---------------------------------------------------------------------------
    # Error message for unexpected exceptions
    #---------------------------------------------------------------------------
    ERRMSG  = '%(funName)s: Unexpected exception.\n'
    ERRMSG += '  Exception  type: %(Type)s\n'
    ERRMSG += '  Exception value: %(value)s'

    #---------------------------------------------------------------------------
    # Warning message for "bad" MBean names
    #---------------------------------------------------------------------------
    WARNING  = '%(funName)s:\n'
    WARNING += "Warning: Specified MBean name doesn't start with "
    WARNING += '"%(domain)s" and is ignored.\n  MBean name: "%(beanName)s"'

    try :
        #-----------------------------------------------------------------------
        # Verify that we are working with a WebSphere MBean
        #-----------------------------------------------------------------------
        if beanName.startswith( domain ) :
            #-------------------------------------------------------------------
            # The rest of MBean name only has comma separated name=value pairs
            #-------------------------------------------------------------------
            for field in beanName[ len( domain ): ].split( ',' ) :
                name, value = field.split( '=', 1 )
                result[ name ] = value
        else :
            print WARNING % locals()
    except :
        Type, value  = sys.exc_info()[ :2 ]
        print ERRMSG % locals()
    return result

#-------------------------------------------------------------------------------
# Name: anonymous
# Role: This where script execution appears to begin
#-------------------------------------------------------------------------------
if __name__ in [ '__main__', 'main' ] :
    attr = [ a.strip() for a in attributes.split( ',' ) ]
    fh = open( fileName, 'w' )
    for me in AdminControl.queryNames("*:type=J2CMessageEndpoint,*").splitlines() :
        ok, result, d = 1, {}, MBnameAsDict( me )
        for a in attr :
            if d.has_key( a ) :
                result[ a ] = d[ a ]
            else :
                ok = 0
                print 'Required attribute "%s" missing from bean: %s' % ( a, me )
        if ok :
            fh.write( 'name=%(name)s,J2EEApplication=%(J2EEApplication)s,*\n' % result )
    fh.close()
else :
    print '\nError: script must be executed, not imported.\n'
    print 'Usage: wsadmin -f %s' % __name__

Open in new window


And let me know if it suits your needs
Yes..this the one what i am looking for as script1 Output.  please find the attachment of the output I got. Can we use this as input for script 2 and 3 or we can club both Script 2 and 3 into same script.
OutPut2.txt
Q: Can we use this as input to script # 2 (and if needed #3)?
A: Sure.

Based upon the J2CMessageEndpoint MBean documentation, these are the possible responses to the getStatus() method call:

1 = Active
2 = Inactive
3 = Stopped

So, your next question is:

Q: Can we use this MBean information to determine if the MBean exists,
     if it does invoke getStatus(), and if the result is 2 (i.e., Inactive), invoke the "resume" method call to try and restart it.
A:  Sure... working on this now.

The problem with your description of script #3 is that no information exists that be used to "recycle the app".

Q: What do you want done if the status == 3 (i.e., stopped)?
Try this for script #2
meResume.py
Hi HonorGod,
 Amazing....! Looks like script is working as expected after changing the below value:
if argc != 1 :
to
if argc < 2 :

I need to do some more testing and i will get back to you tomorrow.

here are the steps i did for testing:

D:\Program Files\IBM\WID7_WTE\runtimes\bi_v7\profiles\qwps\bin>wsadmin.bat -lang jython -f meResume.py OutPut2.txt
WASX7209I: Connected to process "server1" on node qnode using SOAP connector;  The type of process is: UnManagedProcess
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[OutPut
2.txt]"
Processing: OutPut2.txt
Resource active: name=BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint,J2EEApplication=BPCECollector_qnode_server1,*
Resource active: name=BPCECollector_qnode_server1#collector.jar#EventTransformer_J2CMessageEndpoint,J2EEApplication=BPCECollector_qnode_server1,*
Resource active: name=BPEContainer_qnode_server1#b.jar#ServiceSIBusMessageBean_J2CMessageEndpoint,J2EEApplication=BPEContainer_qnode_server1,*
Resource active: name=BPEContainer_qnode_server1#b.jar#_export.com.ibm.bpe.api.sca.BFMJMSJMS_J2CMessageEndpoint,J2EEApplication=BPEContainer_qnode_ser
ver1,*
Resource active: name=BPEContainer_qnode_server1#bpecontainer.jar#ProcessContainerMDB_J2CMessageEndpoint,J2EEApplication=BPEContainer_qnode_server1,*
Resource active: name=EventService#EventServerMdb.jar#EventBusMdbBean_J2CMessageEndpoint,J2EEApplication=EventService,*
Resource active: name=TaskContainer_qnode_server1#taskejb.jar#HTMScheduler_J2CMessageEndpoint,J2EEApplication=TaskContainer_qnode_server1,*
Resource active: name=wpsFEMgr_7.0.0#wpsFEMgrEJB.jar#RecoveryMessageDrivenBean_J2CMessageEndpoint,J2EEApplication=wpsFEMgr_7.0.0,*


D:\Program Files\IBM\WID7_WTE\runtimes\bi_v7\profiles\qwps\bin>wsadmin -lang jython
WASX7209I: Connected to process "server1" on node qnode using SOAP connector;  The type of process is: UnManagedProcess
wsadmin>objectName = AdminControl.queryNames("*:name=EventService#EventServerMdb.jar#EventBusMdbBean_J2CMessageEndpoint,*")

wsadmin>AdminControl.invoke(objectName, 'pause')
''
wsadmin>AdminControl.invoke(objectName, 'getStatus')
'2'

wsadmin>exit

D:\Program Files\IBM\WID7_WTE\runtimes\bi_v7\profiles\qwps\bin>wsadmin.bat -lang jython -f meResume.py OutPut2.txt
WASX7209I: Connected to process "server1" on node qnode using SOAP connector;  The type of process is: UnManagedProcess
WASX7487E: Failed to import script libraries modules: D:\Program Files\IBM\WID7_WTE\runtimes\bi_v7\scriptLibraries\perfTuning\V70\applyPerfTuningTempl
ate.py; Examine the wsadmin log file to determine the problem.
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[OutPut
2.txt]"
Processing: OutPut2.txt
Resource active: name=BPCECollector_qnode_server1#collector.jar#EventConsumer_J2CMessageEndpoint,J2EEApplication=BPCECollector_qnode_server1,*
Resource active: name=BPCECollector_qnode_server1#collector.jar#EventTransformer_J2CMessageEndpoint,J2EEApplication=BPCECollector_qnode_server1,*
Resource active: name=BPEContainer_qnode_server1#b.jar#ServiceSIBusMessageBean_J2CMessageEndpoint,J2EEApplication=BPEContainer_qnode_server1,*
Resource active: name=BPEContainer_qnode_server1#b.jar#_export.com.ibm.bpe.api.sca.BFMJMSJMS_J2CMessageEndpoint,J2EEApplication=BPEContainer_qnode_ser
ver1,*
Resource active: name=BPEContainer_qnode_server1#bpecontainer.jar#ProcessContainerMDB_J2CMessageEndpoint,J2EEApplication=BPEContainer_qnode_server1,*

Resource restarted successfully: name=EventService#EventServerMdb.jar#EventBusMdbBean_J2CMessageEndpoint,J2EEApplication=EventService,*

Resource active: name=TaskContainer_qnode_server1#h.jar#ServiceSIBusMessageBean_J2CMessageEndpoint,J2EEApplication=TaskContainer_qnode_server1,*
Resource active: name=TaskContainer_qnode_server1#taskejb.jar#HTMScheduler_J2CMessageEndpoint,J2EEApplication=TaskContainer_qnode_server1,*
Resource active: name=wpsFEMgr_7.0.0#wpsFEMgrEJB.jar#RecoveryMessageDrivenBean_J2CMessageEndpoint,J2EEApplication=wpsFEMgr_7.0.0,*

D:\Program Files\IBM\WID7_WTE\runtimes\bi_v7\profiles\qwps\bin>wsadmin -lang jython
WASX7209I: Connected to process "server1" on node qnode using SOAP connector;  The type of process is: UnManagedProcess
WASX7487E: Failed to import script libraries modules: D:\Program Files\IBM\WID7_WTE\runtimes\bi_v7\scriptLibraries\perfTuning\V70\applyPerfTuningTempl
ate.py; Examine the wsadmin log file to determine the problem.
WASX7411W: Ignoring the following provided option: [?lang, jython]
WASX7031I: For help, enter: "print Help.help()"
wsadmin>objectName = AdminControl.queryNames("*:name=EventService#EventServerMdb.jar#EventBusMdbBean_J2CMessageEndpoint,*")
wsadmin>AdminControl.invoke(objectName, 'getStatus')
'1'

wsadmin>
sounds good... Let me know how it goes.  Thanks for your understanding.
Behavior is different for stand Alone and Clustered environment.
We need to use more variables to be captured in the Script1 Output and pass it to Script 2.
Attached is the output of the Script1 on the cluster environment. : OutPut-MBeans.txt

Since the Service is running on 2 cluster member Environment, We need to capture the “J2EEServer” value and pass that one to the Script2
And for the Script2, At any point in the cluster environment. Status of the polling is active only on 1 Cluster member. Which gives the result as 1 and for the rest of the Cluster member’s it will be 2 or 3. So the condition we need to check will be, Are we getting the status as 1 on any of the cluster members. If it is not, We need to activate that on only 1 cluster member and should not change the status on the other cluster members.
Here are the output of few cmd’s ran against the Clustered environment.
wsadmin>objectName = AdminControl.queryNames("*:name=ASDINT89_SapPs_OrdMedApp#SDINT89_SapPs_OrdMedcom/bfusa/wps/otc/sca/FlatFileExport#SDINT89_SapPs_OrdMed_J2CMessageEndpoint,*")

wsadmin>AdminControl.invoke(objectName, 'getStatus')
WASX7015E: Exception running command: "AdminControl.invoke(objectName, 'getStatus')"; exception information:
 com.ibm.ws.scripting.ScriptingException: WASX7025E: Error found in String

wsadmin>objectName = AdminControl.queryNames("*:name=ASDINT89_SapPs_OrdMedApp#SDINT89_SapPs_OrdMedcom/bfusa/wps/otc/sca/FlatFileExport#SDINT89_SapPs_OrdMed_J2CMessageEn                             dpoint,J2EEApplication=ASDINT89_SapPs_OrdMedApp,J2EEServer=DEV0_GOLD.AppTarget.dev11-Node01.0,*")
wsadmin>AdminControl.invoke(objectName, 'getStatus')
'2'
wsadmin>objectName = AdminControl.queryNames("*:name=ASDINT89_SapPs_OrdMedApp#SDINT89_SapPs_OrdMedcom/bfusa/wps/otc/sca/FlatFileExport#SDINT89_SapPs_OrdMed_J2CMessageEn                             dpoint,J2EEApplication=ASDINT89_SapPs_OrdMedApp,J2EEServer=DEV0_GOLD.AppTarget.dev12-Node01.0,*")
wsadmin>AdminControl.invoke(objectName, 'getStatus')
'1'
OutPut-MBeans-Dev0.txt
> Behavior is different for stand Alone and Clustered environment.
   That's not terribly surprising. ;-)

> We need to capture the “J2EEServer” value and pass that one to the Script2
   See if meBeans.py matches your needs & expectations

meBeans.py

> Because script #2 (i.e., meResumepy) uses the output of meBeans.py directly, no change is required to use the revised output (except for the correction you noted above).

> At any point in the cluster environment. Status of the polling is active only on 1 Cluster member.
    Won't adding the J2EEServer qualifier resolve this?
Hi,
Script 1 output is just the way wanted on Cluster environment.  Attachment “OutPutOf-meBeans.txt”
For the Script2, if we pass the same output, Our Current script will try to enable the polling of the Application’s on all the Cluster Members, which is not correct. At any point of time, Polling should be enabled only on 1 cluster member.
So the script needs to check the status on all the ClusterMember and if we don’t have the result as 1 on any of those cluster member, then the script need to run the ‘resume’ on any one of the Cluster Member.

HonorGod, that is my plan of approach in the script. You are more than welcome, if you have some suggestions as, I am not able to think of any other approach.

-Ramesh
OutPutOf-meBeans.txt
> Our Current script will try to enable the polling of the Application’s on all the Cluster Members, which is not correct.
   Ah, it was not clear, from your previous update, if you were using the High Availability configuration or the scalable one.

> So the script needs to check the status on all the ClusterMember and if we don’t have the result as 1 on any of those cluster member, then the script need to run the ‘resume’ on any one of the Cluster Member.
   ok, I'm going to have to try to figure out how to do this.

   Can you find out if the ME names for the servers in a cluster include the cluster name?

Thanks
This is how our Naming  for one envi, but it changes for each environment

 
  ServeName   		       Node      	Cluster Name   
  rmrs.AppTarget.WPS1Node.0  WPS1Node    	 rmrs.AppTarget      
  
  rmrs.AppTarget.WPS2Node.0  WPS2Node        rmrs.AppTarget     

  rmrs.Messaging.WAS1Node.0  WAS1Node     	 rmrs.Messaging     
  
  rmrs.Messaging.WAS2Node.0  WAS2Node     	rmrs.Messaging      

  rmrs.Support.WPS1Node.0  WPS1Node 		rmrs.Support     

  rmrs.Support.WPS2Node.0  WPS2Node			rmrs.Support     

Open in new window


-> Ah, it was not clear, from your previous update, if you were using the High Availability configuration or the scalable one.

While our input is something similar as below, Dont the script try to enable the polling on both the servers ?

name=AutoProcessModApp#AutoProcessMod#AutoProcessMod_J2CMessageEndpoint,J2EEApplication=AutoProcessModApp,J2EEServer=DEV0_GOLD.AppTarget.dev11-Node01.0*
name=AutoProcessModApp#AutoProcessMod#AutoProcessMod_J2CMessageEndpoint,J2EEApplication=AutoProcessModApp,J2EEServer=DEV0_GOLD.AppTarget.dev12-Node01.0*


as I said earlier, you are more than welcome to suggest your views about how to approach for the script 2.
Thanks
I'm trying to figure out how best to determine with which cluster a particular Message Engine an MBean is associated.

From the MBean example you provided earlier, it appears that script 2 will have to do a bit of lookup in order to determine with which cluster an ME Mbean is associated.

Given the "query" string from the input file,
Look for an active MBean
- If one is found, extract the cell, node & server name attributes from this MBean
- Use this information to determine the cluster.

How does that sound?
Hi,
I just want to be clear, there are some time’s when the polling will go inactive on all the cluster member’s. At that time, it won’t read the flat files. This script should help us, when those case’s arrive. So that it will activate the polling on any one Cluster member and start reading the flat files.   And previously, for the first two days, my output files and responses are from  stand alone. But please refer to the output from the OutPut-MBeans-Dev0.txt

If you fell like your approach be able to address this issue please go ahead. And let me know, what to do.
> I just want to be clear, there are some time’s when the polling will go inactive on all the cluster member’s.

I'm sorry, but I don't understand.

What polling are you talking about?
All adapter polling scenarios and all adapter types such as flat file, FTP, JDBC and SAP.

With the command’s I provided earlier, it will  be checking the status of the message endpoint associated with an activation specification and restart the polling thread if requires.
Are you talking about the fact that the script is checking which ME beans are active, and attempting to restart the inactive and stopped ones?
Yes, let me give you a scenario
If we have an Envi, where the server’s CM1 and CM2 are clustered, and a application App1 is deployed to that cluster.
And that App1 is used for processing the flat files.
We are using the below values as input for the script2.

name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=CM1*
name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=CM2*

How will the current script2 behave?

From my understanding,
It will check the app1 on CM1 and if it is inactive it start that, with out checking next input string. Even when the app1 on CM2 is Active.  By doing this, if App1 on CM2 is processing any file at that time. It will corrupt the flat file as it is in middle of processing.
So , the Script2 should be capable of,  Checking the status on all the Cluster Member’s before it resume the status on any one of the cluster member.
well, with revisions, I would expect script 2 to:

read record #1, and look for the ME bean on server CM1,
if that bean exists, and is active, leave it along, and move on to the next record.
if it exists, but is stopped, or inactive, check the other cluster members to see if any ME on the clusters is active.  ...

Only if no ME in the cluster is active would an attempt be made to "start" one.

The question remains... which one should be started?!?
I also kind of stuck at that. So, I also don't have an exact answer. But for now. If we make ME bean on CM1 to start out of all Cluster Member's . If should be good. Once I am able to find an answer for that, I will  open a new thread.
Can you get the script to check for all the Cluster member, not just for 2 cluster member environment.
Thanks
Hi HonorGod,
   Did you got chance to look into the update for script 2 ?

Thanks
Somehow I missed your previous update.  Thanks for letting me know (reminding me).

let me try to look at it tonight, or 1st thing tomorrow.
Hi HonorGod,
  Do you have any update on Script2
Thanks..!
Hi HonorGod,
 Do you have any update on Script2 ? If that is too complex, can let me know the issue so we can look for some round-about and get it working on Cluster .
Thanks
Sorry, life intruded this weekend, and today.  I hope to have script#2 updated for you tomorrow morning (Eastern US time)
I have some questions for you.

- In the "normal" case, are there MEbeans for each cluster member?

- What is the "state" of each MEbean?

- Is it possible for a server (cluster member) to have access to multiple Message Engines?

I'm trying to figure out the best way to work with the information generated by script#1.

Thanks
Thank you for responding...!

- In the "normal" case, are there MEbeans for each cluster member?
Yes

- What is the "state" of each MEbean?
If MEBean on CM1 is Active, the rest will be inactive


- Is it possible for a server (cluster member) to have access to multiple Message Engines?

No.



taking the below as Example
name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=CM1*
name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=CM2*

Where the MBean is active on CM1 and inactive on CM2


wsadmin>objectName = AdminControl.queryNames("*:name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=CM1*')
wsadmin>AdminControl.invoke(objectName, 'getStatus')
'1'
wsadmin>AdminControl.invoke(objectName, 'resume')
''
wsadmin>AdminControl.invoke(objectName, 'getStatus')
'1'
wsadmin>objectName = AdminControl.queryNames("*:name=App1_J2CMessageEndpoint,J2EEApplication=App1,J2EEServer=CM2*')

wsadmin>AdminControl.invoke(objectName, 'getStatus')
'1'
wsadmin>AdminControl.invoke(objectName, 'resume')
WASX7015E: Exception running command: "AdminControl.invoke(objectName, 'resume')"; exception information:
 javax.management.MBeanException
java.lang.IllegalStateException: java.lang.IllegalStateException: J2CA0526I: The Message Endpoint for ActivationSpec jndi/App1_J2CMessageEndpoint (com.ibm.j2ca.jdbc.inbound.JDBCActivationSpecWithXid) and MDB Application App1_J2CMessageEndpoint cannot be activated nor deactivated because inbound messaging on ResourceAdapter {2} is currently disabled by the High_Availability (HA) Manager.
What I am looking for now, Is, We Change the input file for Script as we required. (Doesn’t need to be exactly the same as OutPut of Script1) And in Script 2, Have a Condition to check for the status of MBean’s on all the Cluster Members. If none of them returns as active, just change the status of the CM1 MBean. I am looking form Which ever is beast and quick solution is available, we would like to use it. As we need to implement it soon.
So, it would appear that script2 should:

- Determine that an ME bean is active one one of the cluster members, and leave it, and all other cluster ME's alone... right?

- Only if:
  - an ME bean is on a non-cluster, and inactive
  - or ALL cluster ME's are inactive
should it (script2) try to start, or restart an ME.

Right?
Yes. Thats what we are looking for now. And can we captured the list of the MBean's or J2EE Aplication the script is changing the status in each time it ran.
This will help us to determine, how the script is helping our issue.

Thanks
ok, I "think" I have it figured out...

I need to finish the code, and hope to post tonight...
I think that this has a good chance of working.  Please take a look, try it out, and let me know.
meResume.py
Thanks for the updated script...But i am getting the below error:  find the attachment for the input file

[b]wasadmin@dev10-ak-fis bin] $ ./wsadmin.sh -lang jython -f /tmp/meResume.py /tmp/InPutOf-meResume-Dev.txt
Realm/Cell Name: <default>
WASX7209I: Connected to process "dmgr" on node dev10-DEV-CellManager using SOAP connector;  The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[/tmp/InPutOf-meResume-Dev.txt]"
Processing: /tmp/InPutOf-meResume-Dev.txt
Error: resource not found: name=O_SDINT50_JdaSap_OrdMedApp2#SDINT50_JdaSap_OrdMedJDAFTPExport#SDINT50_JdaSap_OrdMed_J2CMessageEndpoint,J2EEApplication=O_SDINT50_JdaSap_OrdMedApp2,J2EEServer=DEV0_GOLD.AppTarget.dev11-Node01.0*
Error: resource not found: name=O_SDINT50_JdaSap_OrdMedApp2#SDINT50_JdaSap_OrdMedJDAFTPExport#SDINT50_JdaSap_OrdMed_J2CMessageEndpoint,J2EEApplication=O_SDINT50_JdaSap_OrdMedApp2,J2EEServer=DEV0_GOLD.AppTarget.dev12-Node01.0*
Error: resource not found: name=O_SDINT7_BfdSap_DelMedApp#SDINT7_BfdSap_DelMedcom/bfusa/wps/otc/sca/FlatFileExport#SDINT7_BfdSap_DelMed_J2CMessageEndpoint,J2EEApplication=O_SDINT7_BfdSap_DelMedApp,J2EEServer=DEV0_GOLD.AppTarget.dev11-Node01.0*
Error: resource not found: name=O_SDINT7_BfdSap_DelMedApp#SDINT7_BfdSap_DelMedcom/bfusa/wps/otc/sca/FlatFileExport#SDINT7_BfdSap_DelMed_J2CMessageEndpoint,J2EEApplication=O_SDINT7_BfdSap_DelMedApp,J2EEServer=DEV0_GOLD.AppTarget.dev12-Node01.0*
Error: resource not found: name=O_SDOMINT88_BsroSap_OrdMedApp#SDOMINT88_BsroSap_OrdMedcom/bfusa/wps/otc/sca/FlatFileExport#SDOMINT88_BsroSap_OrdMed_J2CMessageEndpoint,J2EEApplication=O_SDOMINT88_BsroSap_OrdMedApp,J2EEServer=DEV0_GOLD.AppTarget.dev11-Node01.0*
Error: resource not found: name=O_SDOMINT88_BsroSap_OrdMedApp#SDOMINT88_BsroSap_OrdMedcom/bfusa/wps/otc/sca/FlatFileExport#SDOMINT88_BsroSap_OrdMed_J2CMessageEndpoint,J2EEApplication=O_SDOMINT88_BsroSap_OrdMedApp,J2EEServer=DEV0_GOLD.AppTarget.dev12-Node01.0*
Exception encountered:
  Type: exceptions.NameError
 value: configIdAsList[/b]

InPutOf-meResume-Dev.txt
OutPutOf-meBeans-Dev.txt
Hi,
 I did little Homework, and corrected the input file. after passing the correct input file, i am getting below message
Please fine the attached input file.

wasadmin@dev10-ak-fis bin] $ ./wsadmin.sh -lang jython -f /tmp/RammiMeResume.py /tmp/InPutOf-meResume-Dev.txt
WASX7209I: Connected to process "dmgr" on node dev10-DEV-CellManager using SOAP connector;  The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[/tmp/InPutOf-meResume-Dev.txt]"
Processing: /tmp/InPutOf-meResume-Dev.txt
Exception encountered:
  Type: exceptions.NameError
 value: configIdAsList

InPutOf-meResume-Dev.txt
I'm sorry, that's a typographical error in line 140:

Currently it looks like (without the proper indentation):
----------------------------------------------------------------------
members = configIdAsList( AdminConfig.showAttribute( cluster, 'members' ) )
----------------------------------------------------------------------

The problem is that the function that it is supposed to be calling has a slightly different name:

----------------------------------------------------------------------
configIdsAsList( )
----------------------------------------------------------------------

instead of:

----------------------------------------------------------------------
configIdAsList(
----------------------------------------------------------------------

See where it (configIdsAsList) is defined in line 12.

So, change the "configIdAsList" line 140 to be "configIdsAsList" instead.

Note: Ids should be plural.
ASKER CERTIFIED SOLUTION
Avatar of sweety_745
sweety_745
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
wow, the cluster checking code looks to be working fine...

Excellent.

Please let me know how the additional testing goes.
i think script is not checking all the Values in the input file. it is breaking after checking  status for one.
Even i paused the polling for one Activation spec. it didn't changed the status.
i got the below , i didn't show which adapter is it trying to check the status and which one it started.

WASX7209I: Connected to process "dmgr" on node dev10-DEV-CellManager using SOAP connector;  The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[/tmp/InPutOf-meResume-Dev.txt]"
Processing: /tmp/InPutOf-meResume-Dev.txt
Resource restarted successfully: member = DEV0_GOLD.AppTarget.dev12-Node01.0  node = dev12-Node01
I am doing more research on this . Can be hold for now on Script 2.

Thanks
It only "breaks" when it it processing all of the beans that exist for a cluster, and an attempt to resume the MBbean results in a status of "1" (i.e., Active). [See line 155]

How many clusters do you have?

How many members in each cluster?

You might consider adding one or more print statements to the resume() routine to determine which bean is being processed, and the result...

You might also consider commenting out line 155 to see what happens when you attempt to resume() all MEbeans in a cluster
sorry, i did get chance to look at this last week. but will update you by End of Day today.

Thanks
Did you get a chance to test this?
===>How many clusters do you have?

Ours is a GoldenTopology, We have 3 Cluster's, one for AppTargets, One for Messaging and one for Support.

All the app's which i need to check the polling status is on AppTarget cluster.

===>How many members in each cluster?

Each Cluster got two Cluster Member's

I tried the way you mentioned, but I still see , the script is not reading all the values in the input file.
Can you get me a script which will just show me the status of the Adapter polling on which one is active.
just check the condition on both Cluster member and print the status on which one is active.
I am not looking for starting /resume the adapter polling for now. once I have that script I will close this thread.

I am researching more on, if the Adapter polling is inactive on both, which cluster member. Once I have an answer, I will open a new thread.
I just want to rephrase  my previous statement. Once I have the script for just checking the status on Adapter polling on both Cluster Members. I will close this thread with points as solution.
63 comments, clarifications, suggestions, and examples... and 0 points... ouch
Got the solution I want