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. Can a script DCI return multiple variables/DCIs?

Can a script DCI return multiple variables/DCIs?

Scheduled Pinned Locked Moved Support
4 Posts 3 Posters 15.2k 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.
  • M
    M
    mmarin11
    wrote on last edited by
    #1

    Dear community

    I'm looking for a way to create a Dashboard with all BGP sessions that are down from multiple devices. The way I'm doing it is creating independent DCIs under the NetXMS server that return tables and other variables and then include the data in a Dashboard. Is it possible to return multiple variables using the same script? For example, return a table, an integer DCI, a string, etc. The idea would be to use a single script instead of multiple ones.

    Probably there is better way to achieve same report

    Your input would be appreciate it

    Thank you

    1 Reply Last reply
    0
    • A
      A
      Alex Kirhenshtein
      wrote on last edited by
      #2

      There are multiple ways to achieve that.
      If it's ok for you to query data multiple times - just extract common code into a script in the library, then use it in the transformation / wrapper scripts:

      // Library script "lib1"
      function collect() {
        // collect data and return as array of records
      }
      
      // transformation script on the DCI or source script:
      records = lib1::collect();
      return records[0]; // add logic here
      
      // for tables:
      records = lib1::collect();
      t = Table(); // or use $1 if it's transformation script
      t->addColumn("col1"); // required only when creating table from scratch
      t->addColumn("col2");
      for (r : records) { // add logic here
         row = t->addRow();
         t->set(row, 0, r[0]);
         t->set(row, 1, r[1]);
      }
      

      Another option is to create table DCI, then use this DCI as data source for any other, e.g.:

      // GetDCIValue() and GetDCIValueByDescription() might be usefull (see https://www.netxms.org/documentation/nxsl-latest/#_data_collection)
      t = GetDCIValueByName($node, "My.Table.DCI"); // result will be either String or Table object
      return t->findRowByInstance("peer1")->get("col1"); // you can use  either column names or indexes in get()
      
      1 Reply Last reply
      0
      • F
        F
        Filipp Sudanov
        wrote on last edited by
        #3

        Another option could be to create push DCIs use PushDCIData(). You can e.g. do this from a transormation script of of another DCI.

        1 Reply Last reply
        0
        • M
          M
          mmarin11
          wrote on last edited by
          #4

          Thanks Alex/Filipp

          I will try proposed options.

          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