Template DCI & Instance name in transformation script
-
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->descriptionto 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 -
-
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. 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login