Author Topic: Add snmp Values together  (Read 1436 times)

letabawireless

  • Newbie
  • *
  • Posts: 12
    • View Profile
Add snmp Values together
« on: June 27, 2017, 05:49:21 pm »
Hi

Forgive me if this question is trivial, but I am not sure how to do it. I have two SNMP values from 2 different nodes. I take the average delta / second, as this is my bandwidth usage. I would like to add two sites together to get my total usage. So, add the two values together, and then get the average delta / sec. Not sure where to start, and what route to take. Many thanks for an awesome program !!

Wimpie

Victor Kirhenshtein

  • Lead Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 7036
    • View Profile
Re: Add snmp Values together
« Reply #1 on: June 28, 2017, 12:30:05 am »
Hi,

you'll have to use scripts. There are two slightly different options:

1. create new script in script library that will use GetDCIValueByName or GetDCIValueByDescription to read current values from two DCIs and return their sum. Then create new script DCI on any node.

2. Use transformation script on one of the nodes to read value from other node and return sum of two values.

Best regards,
Victor

letabawireless

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Add snmp Values together
« Reply #2 on: June 28, 2017, 10:38:10 am »
Hi Victor

As I am not good at scripting in this language, could you possibly give a link for some examples ? I will opt for option 2, so I will duplicate the same DCI, and then add the other DCI value to this one.

Thank you

letabawireless

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Add snmp Values together
« Reply #3 on: June 28, 2017, 12:14:06 pm »
Ok, I have tried the following:

I created to scripts, one for the upload, and one for the download:

sub myTotalDownload()
{
result = GetDCIValueByDescription($nodedesc) + GetDCIValueByDescription($nodedesc);
}

Then I added a DCI, and chose the script as origin, and Data Type Unsigned 64bit.

On transformation, I chose avg delta per second.

I don't get a value - what am I missing ?



Tursiops

  • Sr. Member
  • ****
  • Posts: 476
    • View Profile
Re: Add snmp Values together
« Reply #4 on: June 28, 2017, 02:25:33 pm »
The following should work:

Create a script called "MyScript" with the following code:
Code: [Select]
node1 = FindNodeObject($node,"NODE1_NAME");
node2 = FindNodeObject($node,"NODE2_NAME");
dci1 = GetDCIValueByDescription(node1,"DCI1_DESCRIPTION");
dci2 = GetDCIValueByDescription(node2,"DCI2_DESCRIPTION");
return dci1 + dci2;

Replace NODE1_NAME and NODE2_NAME with the object names of the nodes holding your data.
Replace DCI1_DESCRIPTION and DCI2_DESCRIPTION with the DCI descriptions.

Create a new DCI on a node, select type "Script" and select the "MyScript" you created earlier.
You do not need to use a delta transform for this, as you already transformed the other two DCIs.

If you do not get any result, there may be a typo in one of the node names or DCI descriptions or you may have the trusted node check enabled (that's the default) and NODE1_NAME and/or NODE2_NAME do not contain the node you're running the script on in the list of trusted nodes. You can confirm if that's the issue by setting the server configuration variable CheckTrustedNodes to 0 and restarting the NetXMS server.
You can always just right-click on a node and "Execute Server Script" and select "MyScript" to see what's happening when you execute it.

Documentation references:
https://wiki.netxms.org/wiki/NXSL:FindNodeObject
https://wiki.netxms.org/wiki/NXSL:GetDCIValueByDescription
https://wiki.netxms.org/wiki/SG:Security_Issues

Cheers