Calculating monthly speeds over 95th percentile?

Started by Millenium7, May 08, 2023, 08:03:07 AM

Previous topic - Next topic

Millenium7

I want to create a DCI on nodes that have leased fiber lines. We pay for a particular speed i.e. 500/500mbit but the line is actually burstable much higher to i.e. 10gbit/10gbit. We do not pay for bursting, however we do get billed significantly extra if we exceed the provisioned speed for more than 5% of the billing cycle

I can see there is an example NetXMS script for 95th percentile packet loss, but this isn't directly applicable
I'm already polling interface speeds every 5 minutes, how can I create another DCI that can calculate the average speed so far the current month, and then use thresholds to alert at 50%, 85%, 95% etc


Filipp Sudanov

dciId = 2531;
threshold = 500 * 1000 * 1000;

t = localtime();
t->hour = 0;
t->min = 0;
t->sec = 0;
endTime = mktime(t);

if (t->mon >= 2) {
  t->mon = t->mon - 1;
}
else
{
  t->mon = 12;
  t->year = t->year - 1;
}
startTime = mktime(t);

a = GetDCIValues($node, dciId, startTime, endTime);

HighCnt = 0;
Cnt = 0;

for (v : a) {
  Cnt++;
  if (v > threshold) HighCnt++;
}

return HighCnt / Cnt;

Here's an example script that grabs all values for a DCI for last month. You can put this in a script DCI that is being collected by cron schedule on the first day of each month.

Once you nave array with values, you can do various calculations with them. If you want to do calculations that involve big numbers, e.g. calculating average value, initialize variable like that:

TotalCounter = 0L;

This will use INT64 for this variable.