Is there a way to insert the {instance-name} into a transformation script? I have a Dummy DCI, "Total traffic on {instance-name} (bits/sec)" that sums 2 other DCIs and returns sum. I'd like to apply this DCI via templates.
Template DCI transformation script:
In = GetDCIValue($node, FindDCIByDescription($node, "Inbound traffic on " . {instance-name} . " (bits/sec)"));
Out = GetDCIValue($node, FindDCIByDescription($node, "Outbound traffic on " . {instance-name} . " (bits/sec)"));
if ( In == null && Out == null )
return 0;
if ( In == null && Out != null )
return Out;
if ( In != null && Out == null )
return In;
return In + Out;
Template DCI Instance Discovery:
SNMP Walk - OIDs
Base SNMP OID: .1.3.6.1.2.1.31.1.1.1.1
Filter script:return %(true, $1, $2);
I've tried replacing {instance-name} with $2 but no luck. Any help is appreciated.
I'm doing something similar and use $dci->description to get name + instance of the dummy DCI.
In your case, you need additional some string operations.
Hi,
try to use $dci->instance like this:
In = GetDCIValue($node, FindDCIByDescription($node, "Inbound traffic on " . $dci->instance . " (bits/sec)"));
[code]
Best regards,
Victor
Thanks Victor. That seems to work. The transformation script in the Node DCI is the same as in the Template DCI. How does $dci->instance work exactly? Is there documentation of this feature anywhere?
Again, thanks for your help!!
This is slightly off topic, so I can create new post if you like. Is there a way to change the DCI status to Disabled during Instance Discovery? I've tried the following in a Template DCI instance discovery, but it doesn't work:
snmp = CreateSNMPTransport($node);
if (snmp == null)
$dci->status = 1;
oid = ".1.3.6.1.2.1.2.2.1.8." . $1;
ifOper = SNMPGetValue(snmp, oid);
if ( ifOper != 1 )
$dci->status = 1; }
return %(true, $1, $2);
This is supposed to check ifOper status and disable the DCI of the status is not UP.
$dci is global variable containing reference to current DCI object. You can find class description here: https://wiki.netxms.org/wiki/NXSL:DCI (https://wiki.netxms.org/wiki/NXSL:DCI). Instance is it's attribute.
Transformation scripts in templates never executed - it is just a template for real DCIs.
It is not possible to disable DCI from script.
Best regards,
Victor