Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. WMI query returns codes

WMI query returns codes

Scheduled Pinned Locked Moved Support
7 Posts 3 Posters 34.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    R
    ravi2904
    wrote on last edited by
    #1

    Hi Victor,

    Some WMI queries return code numbers. For example, WMI.Query(root\CIMV2, Win32_Processor, Architecture) returns 0 for x86, 9 for x64. How to write a script which can transform the result ? Some example will be really helpful, as there are lot of queries which return code numbers. I am configuring the queries in DCI configuration.

    Thanks in advance,

    Ravi

    1 Reply Last reply
    0
    • F
      F
      Filipp Sudanov
      wrote on last edited by
      #2

      So, transformation scripts, as well as other scripts in NetXMS are written in NXSL - custom scripting language. It's syntax is resembling C language syntax. Language documentation can be seen here: https://www.netxms.org/documentation/nxsl-3.0/

      Here's a sample script:

      if ($1 == 9) {
        return "x64";
      }
      else if ($1 == 0)
      {
        return "x86";
      }
      else
      {
        return "unknown: ".$1;
      }
      

      $1 is the raw value (after step 1 of transformation), so in this case it's either 0 or 9. Other variables are also available in the script, e.g. $node in the node object to which the DCI belongs to. $node->name would be the name of the node.

      You can use trace function to print debug information to server's log file, first parameter of trace is debug level on which the information is printed

      trace(0, $node->name)
      

      P.S. For me only the following syntax of the parameter worked on Win7:
      WMI.Query(root\CIMV2,SELECT * FROM Win32_Processor, Architecture)

      1 Reply Last reply
      0
      • V
        V
        Victor Kirhenshtein
        wrote on last edited by
        #3

        Small addition: if you have lot of values to convert or they change frequently you may want to create mapping table on the server (via Configuration -> Mapping Tables) and use NXSL function map (https://www.netxms.org/documentation/nxsl-3.0/#func-map) to map code to text.

        Best regards,
        Victor

        1 Reply Last reply
        0
        • R
          R
          ravi2904
          wrote on last edited by
          #4

          Thank you so much Filipp  and Victor. I added the script in the transformation and it is working fine. Great.

          Another query I had, some of the WMI queries return a list, for example, WMI.Query(root\CIMV2, select * from Win32_LogicalDisk, caption), will return the list containing all the drives i.e. C:, D:, E: etc. How can I address this ? Also, , is it possible anyway, to a different row in raw_dci_values for each of these,  like - Caption: C:, Free Space: 87982829 bytes.

          Secondly, in the Object details screen, we get the capabilities list, which displays what kind of device it is, e.g. Printer, Bridge, Router etc. I think this comes from the nodes table from the column capabilities. If it is so, how does the "capabilities" column represent the description, since it contains a long integer. Can you explain this to me ? I needed this info to display in a different screen.

          Thanks a lot.

          Best regards,

          Ravi

          1 Reply Last reply
          0
          • F
            F
            Filipp Sudanov
            wrote on last edited by
            #5

            Currently WMI subagent does not support data presentation as table or list, it just takes first from received values. We are planning to implement this at some point of time.

            Capabilities are stored as a bitfield in that long integer, here you can find which bit represents what capability: https://www.netxms.org/documentation/datadictionary-3.0/#t-nodes

            1 Reply Last reply
            0
            • F
              F
              Filipp Sudanov
              wrote on last edited by
              #6

              Support for WMI queries returning lists or tables will be made available in 3.1 version.

              1 Reply Last reply
              0
              • R
                R
                ravi2904
                wrote on last edited by
                #7

                Thank you so much for all the info. I look forward for the 3.1 version.

                Thanks and best regards,

                Ravi.

                1 Reply Last reply
                0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                Powered by NodeBB Contributors
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups