NetXMS Support Forum

English Support => General Support => Topic started by: it_user1 on May 07, 2018, 04:10:09 PM

Title: help with aggregate DCI
Post by: it_user1 on May 07, 2018, 04:10:09 PM
Hi, i'm configuring node for my exchange server and i need to create a dci that is the average of this performance counter

\MSExchange ADAccess Domain Controllers(DC)\LDAP Search Time

for all my domain controllers.

can someone help me? give me an input to create a script?

thank you

Andrea


Title: Re: help with aggregate DCI
Post by: Victor Kirhenshtein on May 14, 2018, 11:08:19 PM
Hi,

you can create another script DCI with script like this:


return GetAvgDCIValue($node, FindDCIByName($node, "\\MSExchange ADAccess Domain Controllers(DC)\\LDAP Search Time"), time() - 3600, time());


It will return average value for last hour. Note that \ are doubled in DCI name because it is an escape character in NXSL string.

Best regards,
Victor
Title: Re: help with aggregate DCI
Post by: it_user1 on May 15, 2018, 05:25:19 PM
Hi, thank you for reply, but i need to create a dci with average value of these DCI (i have 4 domain controllers)

\\MSExchange ADAccess Domain Controllers(DC1)\\LDAP Search Time
\\MSExchange ADAccess Domain Controllers(DC2)\\LDAP Search Time
\\MSExchange ADAccess Domain Controllers(DC3)\\LDAP Search Time
\\MSExchange ADAccess Domain Controllers(DC4)\\LDAP Search Time

I need to create a new dci with value that is average of these DCI's value.

I understood that i need to create a script and after link this script to a new DCI.

thank you

Andrea
Title: Re: help with aggregate DCI
Post by: Tursiops on June 07, 2018, 04:18:07 PM
Hi,

The following should work.


searchTimeTotal = 0;
activeDCIs=0;
foreach (dci : FindAllDCIs($node,"\\MSExchange ADAccess Domain Controllers(*)\\LDAP Search Time") )
{
dciValue = GetDCIValue($node,dci->id);
if ( dciValue == null ) continue; // To skip in case of errors
searchTimeTotal+=dciValue;
activeDCIs++;
}
return format((searchTimeTotal/activeDCIs),2); // You may want to change the number of decimals or round instead.


Cheers
Title: Re: help with aggregate DCI
Post by: Egert143 on September 15, 2019, 02:41:55 PM
Hello

Sorry for digging up an old topic. Is this script supposed to work with current version ?

I made new script out of it and changed line:

"foreach (dci : FindAllDCIs($node,"\\MSExchange ADAccess Domain Controllers(*)\\LDAP Search Time") )"
to
"foreach (dci : FindAllDCIs($node,"Cpu *") )".

then added new dci with origin script and parameter selected as above script, i get result: -nan(ind) / result 0.

data looks like:

Cpu 1, Cpu 2, Cpu 3 etc. What am i dooing wrong ?
Title: Re: help with aggregate DCI
Post by: Victor Kirhenshtein on September 15, 2019, 06:21:02 PM
Hi,

yes, script is valid, but you have to remember that it search DCIs by name (parameter name). Are you sure you have parameter names Cpu 1, etc. and not DCI descriptions?

Best regards,
Victor
Title: Re: help with aggregate DCI
Post by: Egert143 on September 16, 2019, 08:17:47 AM
Nice got that bit to work, indeed i was mixing parameter name and description.

But i have one tiny problem still: The cpu dci-s are auto generated by instance, and ".1.3.6.1.2.1.25.3.3.1.2.{instance}" counts as result also when searching with "foreach (dci : FindAllDCIs($node,".1.3.6.1.2.1.25.3.3.1.2.*") )", how can i filter that one out ?

Title: Re: help with aggregate DCI
Post by: Victor Kirhenshtein on September 16, 2019, 10:56:01 AM
You can do something like

for (dci : FindAllDCIs($node, ".1.3.6.1.2.1.25.3.3.1.2.*"))
{
   if (dci->name like "*{instance}")
      continue;
   // your code here
}


Best regards,
Victor
Title: Re: help with aggregate DCI
Post by: Egert143 on September 16, 2019, 02:03:33 PM
When i add "dciValueB = GetDCIValue($node,dci->name);" then i already get dci unsupported error.

When i use "if (dci->name like "*{instance}") continue;" it doesent match.
Title: Re: help with aggregate DCI
Post by: Tatjana Dubrovica on September 16, 2019, 03:39:34 PM
Quote from: Egert143 on September 16, 2019, 02:03:33 PM
When i add "dciValueB = GetDCIValue($node,dci->name);" then i already get dci unsupported error.

When i use "if (dci->name like "*{instance}") continue;" it doesent match.

You should do: "dciValueB = GetDCIValue($node,dci->id);"
As GetDCIValue requires node object and DCI id as a parameters: https://www.netxms.org/documentation/nxsl-3.0/#func-getdcivalue
Title: Re: help with aggregate DCI
Post by: Victor Kirhenshtein on September 16, 2019, 04:52:57 PM
Quote from: Egert143 on September 16, 2019, 02:03:33 PM
When i use "if (dci->name like "*{instance}") continue;" it doesent match.

Please share full script code. I checked on my system and it works as expected.

Best regards,
Victor
Title: Re: help with aggregate DCI
Post by: Egert143 on September 16, 2019, 06:02:26 PM
searchTimeTotal = 0;
activeDCIs=1;

foreach (dci : FindAllDCIs($node,".1.3.6.1.2.1.25.3.3.1.2.*") )
{

dciValue = GetDCIValue($node,dci->id);

if ( dci->name like "*{instance}" ) continue;


if ( dciValue == null ) continue;


searchTimeTotal+=dciValue;
activeDCIs++;
}

return activeDCIs;
//return round(searchTimeTotal/activeDCIs,2);


Cpu DCI:
Description: Cpu {instance}
parameter: .1.3.6.1.2.1.25.3.3.1.2.{instance}
discovery: snmp walk:.1.3.6.1.2.1.25.3.3.1.2

the result i am looking for should be 36 (36 cores), but i am getting 37 instead.
Title: Re: help with aggregate DCI
Post by: Victor Kirhenshtein on September 16, 2019, 06:50:39 PM
You initialize variable activeDCIs to 1, which gives you incorrect result - if you have 36 cores line

activeDCIs++;

will be execured 36 times and result will be 37.

Best regards,
Victor
Title: Re: help with aggregate DCI
Post by: Egert143 on September 17, 2019, 08:05:12 AM
Such a simple mistake. :) Got it working now, many thanks.
Title: Re: help with aggregate DCI
Post by: Hospital on December 18, 2019, 11:33:48 AM
Thumbs up for this topic! To calculate Total Space Used on all filesystems, into single aggregate DCI:


UsedSpaceTotal=0;
foreach (dci : FindAllDCIs($node,"FileSystem.Used*") )
{
dciValue = GetDCIValue($node,dci->id);
if ( dciValue == null ) continue; // To skip in case of errors
UsedSpaceTotal+=dciValue;
}
return UsedSpaceTotal;