Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Template DCI & Instance name in transformation script

Template DCI & Instance name in transformation script

Scheduled Pinned Locked Moved Support
6 Posts 3 Posters 23.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z
    Z
    zsing82
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • U
      U
      Andreas@rc
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • V
        V
        Victor Kirhenshtein
        wrote on last edited by
        #3

        Hi,

        try to use $dci->instance like this:

        In = GetDCIValue($node, FindDCIByDescription($node, "Inbound traffic on " . $dci->instance . " (bits/sec)"));
        [code]
        
        Best regards,
        Victor
        
        1 Reply Last reply
        0
        • Z
          Z
          zsing82
          wrote on last edited by
          #4

          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!!

          1 Reply Last reply
          0
          • Z
            Z
            zsing82
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • V
              V
              Victor Kirhenshtein
              wrote on last edited by
              #6

              $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

              1 Reply Last reply
              0

              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
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              Powered by NodeBB Contributors
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups