NetXMS Support Forum

Please login or register.

Login with username, password and session length

Author Topic: Interface names in instance discovery  (Read 5515 times)

rgkordia

  • Newbie
  • *
  • Posts: 20
    • View Profile
Interface names in instance discovery
« on: January 15, 2015, 01:23:07 am »

Hi guys,

I've seen a number of posts around this topic, but I'm having trouble getting this to work. 

Problem: when I create a DCI that uses instance discovery (eg: ifInOctets) I can't seem to get the interface description into the name of the DCI.

I've tried using the %{script:xxxxx} approach in the DCI name, but I can't find out how to pass {instance} as a parameter to the script and $dci appears to not be set in the script.
I've tried using the return %(true,"<interface_name>") method in the instance filter, but this breaks the {instance} value for the OID.

Any help on a working solution?

Here's an example of my current DCI config:

Description: Input Bandwidth (bps) on {instance}
SNMP OID: .1.3.6.1.2.1.2.2.1.10.{instance}
Transformation: Delta/sec, and $1 * 8 in the script
Instance discovery: SNMP walk of OID .1.3.6.1.2.1.2.2.1.10

Thanks,
Richard
Logged

tomaskir

  • Sr. Member
  • ****
  • Posts: 435
  • https://unimus.net
    • View Profile
Re: Interface names in instance discovery
« Reply #1 on: January 15, 2015, 07:37:39 am »

UPDATE: Please see this post:
https://www.netxms.org/forum/configuration/interface-names-in-instance-discovery/msg18102/#msg18102

Description: Traffic on {instance-name} - bits/s IN
Parameter: .1.3.6.1.2.1.31.1.1.1.6.{instance}
Origin: SNMP - Unsigned Int 64bit

Transformation: Average delta per sec
Transform script:
Code: [Select]
return $1 * 8;
Instance discovery: SNMP Walk - OIDs
Base SNMP OID: .1.3.6.1.2.1.2.2.1.1
Instance discovery script:
Code: [Select]
transport = CreateSNMPTransport($node);
if (transport == null)
return false;

// get the interface name to return as instance-name
vb = SNMPGet(transport, ".1.3.6.1.2.1.31.1.1.1.1." . $1);
if (vb == null)
return false;

// filter out loopback
if (vb->value == "lo")
return false;

return %(true, $1, vb->value);

Please note the node has to support the IfXTable for this script to work.
« Last Edit: October 24, 2015, 11:52:22 am by tomaskir »
Logged

rgkordia

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Interface names in instance discovery
« Reply #2 on: January 16, 2015, 03:05:09 am »

Perfect.  Thanks Tomaskir.  Now that you pointed this out, I found it in the docs :)  Works like a charm.

Regards,
Richard
Logged

glebofff

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: Interface names in instance discovery
« Reply #3 on: January 16, 2015, 07:44:05 am »

I wonder is there any reasons left to use snmp transport in such cases. We can get all interesting information from $node object and its child interfaces:

Code: [Select]
i = GetInterfaceObject($node, $1);
if (i != null && i->adminState == 1)
{
  return %(true, $1, i->name);
}
return false;
Logged

LBKRE

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Interface names in instance discovery
« Reply #4 on: October 22, 2015, 02:47:38 pm »

Very nice......
but.....
how do i get the "instance name when" i use this DCIs as title in the Performance tab?

"%{node-name} {node-name}" doesn't work.

Greeting from Germany
Ludger
Logged

Victor Kirhenshtein

  • Lead Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 6509
    • View Profile
Re: Interface names in instance discovery
« Reply #5 on: October 24, 2015, 11:44:54 am »

Hi,

try to use {instance} in graph title - it should be replaced with the value seen in Thresholds -> Instance in DCI properties.

Best regards,
Victor
Logged

tomaskir

  • Sr. Member
  • ****
  • Posts: 435
  • https://unimus.net
    • View Profile
Re: Interface names in instance discovery
« Reply #6 on: October 24, 2015, 11:51:19 am »

Also as a side note to discussion about returning interface names.

"SNMPWalk - OIDs" now actually returns value of the OID as $2.

So now, script can look like this:

Instance discovery: SNMP Walk - OIDs
Base SNMP OID: .1.3.6.1.2.1.31.1.1.1.1

Instance discovery script:
Code: [Select]
return %(true, $1, $2);

So NetXMS will push to the script $1 as discovered instance (same as before), but now $2 is pushed to the script as the value of that OID automatically.
This makes the above script possible, and you dont have to use CreateSNMPTransport or GetInterfaceObject anymore.
Logged

sarangtc

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Interface names in instance discovery
« Reply #7 on: September 10, 2018, 07:58:20 pm »

Let me summarize to make it easy for other beginners like me:
for inward traffic (using the 64bit snmp oid)

In "Data Collection Confiugration:"

Description: Traffic on {instance-name} - bits/s IN
Parameter: .1.3.6.1.2.1.31.1.1.1.6.{instance}
Origin: SNMP - Unsigned Int 64bit

Transformation: Average delta per sec
Transform script: $1 * 8

Instance discovery: SNMP Walk - OIDs
Base SNMP OID: .1.3.6.1.2.1.31.1.1.1.1
Instance discovery script: return %(true, $1, $2);



For OUT traffic just change:
Description: Traffic on {instance-name} - bits/s OUT
Parameter: .1.3.6.1.2.1.31.1.1.1.10.{instance}
« Last Edit: September 10, 2018, 08:12:03 pm by sarangtc »
Logged