Transformation script and $dci object

Started by tuomar, June 26, 2014, 01:35:09 PM

Previous topic - Next topic

tuomar

Hi,

I try use (or get) current dci name on the transformation script, but i get error message:
Error 14 in line 8: Function or operation argument is not an object

Script line:
dciName = $dci->name;

My Netxms version is 1.2.14

Rgs
TM


Victor Kirhenshtein

Hi!

Just test it, and it works as expected. Can you please show full script?

Best regards,
Victor

tuomar

Hi,

Sorry, that was my mistake.
Parameter what i need to get is description (http://wiki.netxms.org/wiki/NXSL:DCI).

I created a dummy dci (parameter: Dummy, Origin: Internal, Data Type: string) and here are my simple test scripts:

sub main()
{
dciName = $dci->name;
return dciName;
}

When i click test button it shows error, but when script is "running on the server" the last value tab (and history) shows dummy.

sub main()
{
dciName = $dci->description;
return dciName;
}

When i click test button it shows error, but when script is "running on the server" the last value tab (and history) shows dci description.

sub main()
{
nodeName = $node->name;
return nodeName;
}

When i click test button it shows node name.

Many thanks for your quick reply.


Here is a long story and full script ...and sorry my bad english :)

I try build dashbord that shows network statistic (eg. uplinks traffic (bytes/sec), port usage (%), router cpu usage, jne.) or network "heatmap". Users that can see this dashboard does not need see any other data on the devices.

First at all i created "readonly" user that only have rights to the one dashboard, but then i get errors that user does not have nesessary rights to read the dci data. So next i give read right to Device container and now dashboard works ok, but user see too much data on devices (and can do snmp walk).
I didn't found any option to give rights to only read dci data, so now i try create dummy object that have nesessary dcis.

I hope that there is is a another way to do this kind of dashboard, so any tips/ideas are more than wellcome  :D

This is script and now it works, but if i click test button i get error.

sub main()
{
//Custom attribute "source_node"
value_sourceNode = GetCustomAttribute($node, "source_node");

//DCI description, it will need to be same as dci what we want read
dciDescription = $dci->description;

value_SourceObject = FindNodeObject($node, value_sourceNode);
value_DCIid = FindDCIByDescription(value_SourceObject, dciDescription);
value_DCIdata = GetDCIValue(value_SourceObject, value_DCIid);
return value_DCIdata;
}


Rgs
TM

Victor Kirhenshtein

Hi!

Currently there are no other way to show dashboard without giving read access to nodes where data is collected, so your approach is absolutely right.

As for the script, it's actually a bug - in test mode $dci variable is not set. I'll fix it in the next release.

Best regards,
Victor