NetXMS Support Forum

English Support => General Support => Topic started by: Marco Incalcaterra on December 08, 2013, 07:12:02 PM

Title: Cumulative network traffic
Post by: Marco Incalcaterra on December 08, 2013, 07:12:02 PM
I grab the Victor's suggestion present in this post:

https://www.netxms.org/forum/general-support/summary-of-network-traffic-1387/msg6048/#msg6048

And I wrote my transformation for the Internal DCI in this way (keeping the original value):

sub getValue(paramDescr)
{
obj = FindDCIByDescription($node, paramDescr);
if (obj != null)
{
   dci = GetDCIObject($node, obj);
   if (dci != null && dci->status == 0 && dci->errorCount == 0)
   {
    val = GetDCIValue($node, dci->id);
    if (val != null)
   return val;
  }
}
   return 0;
}

return $1+getValue("_HF - Download on eth0 (bytes)");


My problem is that I'm getting exactly the value of the original DCI ("_HF - Download on eth0 (bytes)"). Where am I wrong?

Do you have a suggestion on how to reset the counter once per month still mantaining an history (even in another DCI)? The goal is to obtain network traffic statistics per each month.

Best regards,
Marco
Title: Re: Cumulative network traffic
Post by: Victor Kirhenshtein on December 09, 2013, 08:20:51 AM
You returning value of original DCI in your transformation script, but if you want cumulative counter, you should return sum of current value of your dummy DCI and current value of original DCI, something like

GetDCIValue($node, dci->id) + GetDCIValue($node, $dci->id)

($dci refers to current DCI being processed).

And to reset the counter - check if last poll time for your dummy DCI is in different month, and return 0 in that case, like this:

if (strftime("%m", $dci->lastPollTime) < strftime("%m", time()))
   return 0;

Best regards,
Victor
Title: Re: Cumulative network traffic
Post by: Marco Incalcaterra on December 09, 2013, 09:25:27 PM
Hi Victor,

it works, thank you for your help. Do you have a suggestion on how to store cumulative values month by month (e.g. traffic for january, february, etc.)?

I have a suggestion for the transformation editor: add the line numbers, if the script is long it is difficult to reach the line indicated by the error message without manually counting the lines.

Best regards,
Marco
Title: Re: Cumulative network traffic
Post by: Victor Kirhenshtein on December 10, 2013, 09:27:07 AM
Hi!

You can create new internal DCI with custom schedule to run once per month and either read current value of cumulative counter in transformation script. The tricky part is timing to ensure that monthly DCI runs before cumulative counter resets at month change. Alternative option could be storing value temporarily in node's custom parameters - when cumulative counter resets, it stores it's current value into some custom attribute, and then monthly DCI reads it.

Best regards,
Victor