Topic
  • 19 replies
  • Latest Post - ‏2013-01-29T17:55:37Z by msmps
samanderson
samanderson
172 Posts

Pinned topic get MQFSH object names and its op state and administrative state with curl

‏2011-04-06T15:12:35Z |
Hi folks,

Can some one help with sample soma file to get list of MQFSH object names and its op state and Administrative State properties alone.
Updated on 2013-01-29T17:55:37Z at 2013-01-29T17:55:37Z by msmps
  • swlinn
    swlinn
    1348 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2011-04-06T16:05:27Z  
    To get a specific MQ FSH:

    <dp:get-config class="MQSourceProtocolHandler" name="mqFSHobjectName" />

    To get all MQ FSHs, just drop the name attribute.

    You'll get the entire object(s) config, including the object name and mAdminState.

    Regards,
    Steve
  • samanderson
    samanderson
    172 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2011-04-06T18:29:28Z  
    • swlinn
    • ‏2011-04-06T16:05:27Z
    To get a specific MQ FSH:

    <dp:get-config class="MQSourceProtocolHandler" name="mqFSHobjectName" />

    To get all MQ FSHs, just drop the name attribute.

    You'll get the entire object(s) config, including the object name and mAdminState.

    Regards,
    Steve
    Thanks steve. This doesnt return Op state(up or down) I see through objects -->mqfsh tab. However need to populate only admin state and op state for now. No need of all the other properties.
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2011-04-06T19:42:17Z  
    You can also do,

    <dp:get-config class="ObjectStatus"> which will give you op-state up and down. But the thing is you will also get the default state objects.

    Kumar
  • swlinn
    swlinn
    1348 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2011-04-06T22:23:03Z  
    You can also do,

    <dp:get-config class="ObjectStatus"> which will give you op-state up and down. But the thing is you will also get the default state objects.

    Kumar
    You would need a dp:get-status, not a dp:get-config, with the class of ObjectStatus, but that gives you the status of every object in the domain. It will have the op and admin state of those objects, but you'll need to xpath through the results to get the MQ FSH objects you wish to see. There is nothing in the XMI schema that would allow you to minimize the results to just a particular class of objects.

    Regards,
    Steve
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2011-04-06T22:31:52Z  
    Sorry for the typo.Steve is right you need <dp:get-status>.
  • HermannSW
    HermannSW
    4894 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2011-04-07T10:46:48Z  
    > However need to populate only admin state and op state for now. No need of all the other properties.

    As Steve pointed out an XPath needs to be applied to the SOMA response.

    Perfect for this is xpath++ tool, from this developerWorks posting:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14511881&#14511881

    Here is the direct download link:
    http://stamm-wilbrandt.de/en/xsl-list/xpath++

    One of the cool features of xpath++ tool is, that you might pass "-" (input redirection) as <XML file> (usage: xpath++ <XPath expression> <XML file>).

    So you are already using curl to send the XML Management query.
    You might find my little bash script doSoma useful (for Linux or Cygwin):
    
    $ cat ~/bin/doSoma #!/bin/bash curl -k -s -u $1 --data-binary 
    "@$2" https:
    //$3/service/mgmt/current ; echo $
    


    Now this is the SOMA call to query the ObjectStatus for all objects of default domain:
    
    $ cat ObjectStatus.xml <env:Envelope xmlns:env=
    "http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <dp:request domain=
    "default" xmlns:dp=
    "http://www.datapower.com/schemas/management"> <dp:get-status class=
    "ObjectStatus"/> </dp:request> </env:Body> </env:Envelope> $
    


    Putting that all together with the right XPath this gives the complete solution you asked for:
    
    $ doSoma admin ObjectStatus.xml dp3-l3:5550 | xpath++ 
    "//ObjectStatus[Class='MQSourceProtocolHandler']/*[contains('|OpState|AdminState|Name|',concat('|',name(),'|'))]/text()" - Enter host password 
    
    for user 
    'admin':   ------------------------------------------------------------------------------- down ------------------------------------------------------------------------------- disabled ------------------------------------------------------------------------------- MQ_FSH_1 ------------------------------------------------------------------------------- down ------------------------------------------------------------------------------- enabled ------------------------------------------------------------------------------- MQ_FSW_2 $
    


    Some remarks:
    • I intentionally did not use "admin:password" -- this allows to enter the password and not show it
    • "//ObjectStatus[Class='MQSourceProtocolHandler']" selects all MQ FSHs
    • "/*[contains('|OpState|AdminState|Name|',concat('|',name(),'|'))]" is a tricky way of selecting a name() out of a a set of allowed values (the "|" (alternative) XPath operator only applies to the top level of a XPath statement)
    • "/text()" just outputs the field's text value, not the element itself

     
    Hermann<myXsltBlog/>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-11-29T12:42:30Z  
    Hi,

    Similar to the above requirement, I am trying to get the status of all the probes that are enabled in a particular domain.

    Please let me know your thoughts.

    Thanks
  • Daviiid
    Daviiid
    289 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-11-29T13:32:15Z  
    Hi,

    Similar to the above requirement, I am trying to get the status of all the probes that are enabled in a particular domain.

    Please let me know your thoughts.

    Thanks
    Hello

    YOu nees to do a get config and parse the response to fing debug-mode = 'on'

    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
            <env:Body>
                    <dp:request domain="$domaine" xmlns:dp="http://www.datapower.com/schemas/management">
                            <dp:get-config/>
                    </dp:request>
            </env:Body>
    </env:Envelope>
    


    <DebugMode persisted="false">off</DebugMode>
    
    Updated on 2014-03-25T02:45:28Z at 2014-03-25T02:45:28Z by iron-man
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-11-29T15:08:56Z  
    • Daviiid
    • ‏2012-11-29T13:32:15Z
    Hello

    YOu nees to do a get config and parse the response to fing debug-mode = 'on'

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <dp:request domain="$domaine" xmlns:dp="http://www.datapower.com/schemas/management"> <dp:get-config/> </dp:request> </env:Body> </env:Envelope> </pre>

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><DebugMode persisted="false">off</DebugMode> </pre>
    David little not clear
    there could be different WSP and MPGW services ... Srini's question might be to check if the probe is enabled or disabled ...how can this be achieved ....?

    Thank you!

    Reards,
    Salla
  • Liv2luv
    Liv2luv
    573 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-11-29T15:54:39Z  
    David little not clear
    there could be different WSP and MPGW services ... Srini's question might be to check if the probe is enabled or disabled ...how can this be achieved ....?

    Thank you!

    Reards,
    Salla
    It is only a matter of xpath into the response from the SOAP request posted above:

    */*/*/*/*/DebugMode/../@name will print the object name like wise the object (MPG / WSP can also be printed) by slightly modifying the xpath
  • Liv2luv
    Liv2luv
    573 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-11-29T15:55:28Z  
    David little not clear
    there could be different WSP and MPGW services ... Srini's question might be to check if the probe is enabled or disabled ...how can this be achieved ....?

    Thank you!

    Reards,
    Salla
    It is only a matter of xpath into the response from the SOAP request posted above:
    */*/*/*/*/DebugMode[text()='on']/../@name
    

    will print the object name like wise the object (MPG / WSP can also be printed) by slightly modifying the xpath

    Sorry for the repost. Lost in touch with formatting.
    Updated on 2014-03-25T02:45:23Z at 2014-03-25T02:45:23Z by iron-man
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-11-29T16:04:20Z  
    • Liv2luv
    • ‏2012-11-29T15:55:28Z
    It is only a matter of xpath into the response from the SOAP request posted above:
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">*/*/*/*/*/DebugMode[text()='on']/../@name </pre>
    will print the object name like wise the object (MPG / WSP can also be printed) by slightly modifying the xpath

    Sorry for the repost. Lost in touch with formatting.
    Thank you!

    Regards,
    Salla
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-11-30T06:01:35Z  
    Thank you all for your valuable thoughts. Thanks Salla.

    Reg Srini
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-12-03T13:15:20Z  
    */*/*/*/*/DebugMode/../@name

    Hi,

    The above XPath will provide the output for single object status, not for all the objects. The other alternative approach is finding the object status for each service such as Multiprotocol Gateway, Firewall Service, WebService Proxy. Any other better XPath will be appreciable.

    <xsl:for-each select="/*/*/*/*/*">
    Gateway Debug Status: -->
    <xsl:value-of select="./*/../@name"/> </xsl:for-each>

    <xsl:for-each select="/*/*/*/*/*">
    Firewall Debug Status :
    <xsl:value-of select="./*/../@name"/> </xsl:for-each>

    Thanks, Srini
  • Liv2luv
    Liv2luv
    573 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-12-03T15:06:17Z  
    */*/*/*/*/DebugMode/../@name

    Hi,

    The above XPath will provide the output for single object status, not for all the objects. The other alternative approach is finding the object status for each service such as Multiprotocol Gateway, Firewall Service, WebService Proxy. Any other better XPath will be appreciable.

    <xsl:for-each select="/*/*/*/*/*">
    Gateway Debug Status: -->
    <xsl:value-of select="./*/../@name"/> </xsl:for-each>

    <xsl:for-each select="/*/*/*/*/*">
    Firewall Debug Status :
    <xsl:value-of select="./*/../@name"/> </xsl:for-each>

    Thanks, Srini
    Guess we can do a better xpath way:

    curl -k -u user:pwd -d @getDomainConfig.xml https://server:5550/service/mgmt/current | ..\xmlstarlet-1.0.1\xml.exe sel -T -t -m /*/*/*/*/* -i "DebugMode" -v "concat(local-name(DebugMode[text()='on']/..),',',DebugMode[text()='on']/../@name,' ')"
    


    Output:
    MultiProtocolGateway,ABC
    MultiProtocolGateway,XYZ
    MultiProtocolGateway,Test
    WSGateway,Guess
    XMLFirewallService,AnotherOne

    Thanks
    Updated on 2014-03-25T02:45:03Z at 2014-03-25T02:45:03Z by iron-man
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-12-04T12:52:36Z  
    Fantastic, One of the powerfull expression you have provided integrating with the XMLStarlet command line xml toolkit.

    Thanks, Srini
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-12-21T13:42:22Z  
    Hi,

    The dp:get-config downloads all the object data which is huge to download, any specific soma command to get only enabled or disabled objects.

    Thanks
    Srini
  • HermannSW
    HermannSW
    4894 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2012-12-21T19:07:21Z  
    Hi,

    The dp:get-config downloads all the object data which is huge to download, any specific soma command to get only enabled or disabled objects.

    Thanks
    Srini
    Hi,
    >
    > The dp:get-config downloads all the object data which is huge to download, any specific soma command to get only enabled or disabled objects.
    >
    you can create a service that uses a stylesheet to do the dp:get-config SOMA call and then filters what you want, see:
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/accessing_xml_management_interface_from_within_a_stylesheet38

     
    Hermann<myXsltBlog/> <myXsltTweets/>
  • msmps
    msmps
    193 Posts

    Re: get MQFSH object names and its op state and administrative state with curl

    ‏2013-01-29T17:55:37Z  
    • HermannSW
    • ‏2012-12-21T19:07:21Z
    Hi,
    >
    > The dp:get-config downloads all the object data which is huge to download, any specific soma command to get only enabled or disabled objects.
    >
    you can create a service that uses a stylesheet to do the dp:get-config SOMA call and then filters what you want, see:
    https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/entry/accessing_xml_management_interface_from_within_a_stylesheet38

     
    Hermann<myXsltBlog/> <myXsltTweets/>
    dp:variable('var://service/system/status/ObjectStatus') is giving all the objects status in that domain.

    How can I get the status of all objects that are related to a particular service through stylesheet. Like the objects related to specified WSP or MPGW? Any thoughts?