get values from a DCI table with a tranform script

Started by curruscanis, July 02, 2015, 05:47:10 PM

Previous topic - Next topic

curruscanis

Can someone give me an example of a transform script that pulls a value from a DCI table into a variable?

Victor Kirhenshtein

Line like this:


table = AgentReadTable($node, "System.Processes");


will read agent table (System.Processes in this example) into variable. It will be object variable of class Table. Then you can walk through table using it's methods. For example, to read value of column "NAME" in first row you can use the following code:


colIndex = table->getColumnIndex("NAME");
value = table->get(0, colIndex);


You can iterate through table using rowCount attribute as stop indicator:


for(row = 0; row < table->rowCount; row++)
{
   value = table->get(row, colIndex);
}


Best regards,
Victor

P.S. If you meant transformation script of a table DCI, then you don't need to read table - variable $1 will hold table object.