Transformations Scripts for table DCI

Started by Christian021, April 02, 2014, 05:20:52 PM

Previous topic - Next topic

Christian021

Hi,

NetXMS is a very good programm, i think.
I´ve the following problem with transformation scripts of table dci´s: For example i have a dci named voltage. In this DCI there are three colums: description (string), voltage (integer) and the status (string).
Unfortunally the voltage is with factor 1000 and the status is orgininal an integer (f. ex. 3 = is okay)
Now I want to transform the voltage to the real value (1200 to 1,2) and the status value to an status text (3 = OK).
I have transformation scrips for "simple" parameters - they are working. But they don´t work with table dci.
So I want to ask for help and for an example. Thanks a lot.

Victor Kirhenshtein

Hi!

It could looks like following:


idxVoltage = $1->getColumnIndex("VOLTAGE");
idxStatus = $1->getColumnIndex("STATUS");

for(i = 0; i < $1->rowCount; i++)
{
   $1->set(i, idxVoltage, $1->get(i, idxVoltage) / 1000);
   if ($1->get(i, idxStatus) == 3)
   {
      $1->set(i, idxStatus, "OK");
   }
}


Best regards,
Victor

Christian021

Hi Victor,

thank you so much. I guess, I never match the solution for my problem by myself...
Your solution works fine.

andrey--k

I try to do same.
But result is not set correctly (snmp value is set in place of calculated value).
Screenshot in attach.
transformation script:
Percnt = getColumnIndex("StorageUsedPercent");
Used = getColumnIndex("hrStorageUsed");
Size = getColumnIndex("hrStorageSize");
for (i = 0; i < $1->rowCount; i++)
{
if ( $1->get(i, Used) > 0 && $1->get(i, Size) > 0 )
{
$1->set(i, Percnt, ($1->get(i, Used) / $1->get(i, Size) * 100) );
}
else
{
$1->set(i, Percnt, 0 );
}


Also I have noticed, that there are no any notification if table colums set not right.

How to set Dummy column?

andrey--k

Aditionaly template in attach.

Victor Kirhenshtein

Hi!

getColumnIndex is a method of Table class, so you should use it as $1->getColumnIndex in transformation script, like you do with get method.

Best regards,
Victor