Can a script DCI return multiple variables/DCIs?

Started by mmarin11, June 15, 2021, 12:28:55 AM

Previous topic - Next topic

mmarin11

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


Alex Kirhenshtein

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()

Filipp Sudanov

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

mmarin11

Thanks Alex/Filipp

I will try proposed options.