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:
Another option is to create table DCI, then use this DCI as data source for any other, e.g.:
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:
Code Select
// 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.:
Code Select
// 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()