Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
19 replies Latest Post - ‏2013-01-29T17:55:37Z by msmps
samanderson
samanderson
172 Posts
ACCEPTED ANSWER

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
    1346 Posts
    ACCEPTED ANSWER

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

    ‏2011-04-06T16:05:27Z  in response to samanderson
    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
      ACCEPTED ANSWER

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

      ‏2011-04-06T18:29:28Z  in response to swlinn
      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
    ACCEPTED ANSWER

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

    ‏2011-04-06T19:42:17Z  in response to samanderson
    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
      1346 Posts
      ACCEPTED ANSWER

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

      ‏2011-04-06T22:23:03Z  in response to SystemAdmin
      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
    ACCEPTED ANSWER

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

    ‏2011-04-06T22:31:52Z  in response to samanderson
    Sorry for the typo.Steve is right you need <dp:get-status>.
  • HermannSW
    HermannSW
    4493 Posts
    ACCEPTED ANSWER

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

    ‏2011-04-07T10:46:48Z  in response to samanderson
    > 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
    ACCEPTED ANSWER

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

    ‏2012-11-29T12:42:30Z  in response to samanderson
    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
      282 Posts
      ACCEPTED ANSWER

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

      ‏2012-11-29T13:32:15Z  in response to SystemAdmin
      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
        ACCEPTED ANSWER

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

        ‏2012-11-29T15:08:56Z  in response to Daviiid
        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
          ACCEPTED ANSWER

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

          ‏2012-11-29T15:54:39Z  in response to SystemAdmin
          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
          ACCEPTED ANSWER

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

          ‏2012-11-29T15:55:28Z  in response to SystemAdmin
          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
            ACCEPTED ANSWER

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

            ‏2012-11-29T16:04:20Z  in response to Liv2luv
            Thank you!

            Regards,
            Salla
  • SystemAdmin
    SystemAdmin
    6772 Posts
    ACCEPTED ANSWER

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

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

    Reg Srini
  • SystemAdmin
    SystemAdmin
    6772 Posts
    ACCEPTED ANSWER

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

    ‏2012-12-03T13:15:20Z  in response to samanderson
    */*/*/*/*/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
      ACCEPTED ANSWER

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

      ‏2012-12-03T15:06:17Z  in response to SystemAdmin
      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
    ACCEPTED ANSWER

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

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

    Thanks, Srini
  • SystemAdmin
    SystemAdmin
    6772 Posts
    ACCEPTED ANSWER

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

    ‏2012-12-21T13:42:22Z  in response to samanderson
    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
      4493 Posts
      ACCEPTED ANSWER

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

      ‏2012-12-21T19:07:21Z  in response to SystemAdmin
      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
        192 Posts
        ACCEPTED ANSWER

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

        ‏2013-01-29T17:55:37Z  in response to HermannSW
        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?