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
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
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
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
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 ?
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
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 ?
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
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.
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
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
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.
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
Such a simple mistake. :) Got it working now, many thanks.
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;