help with aggregate DCI
-
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 -
-
@egert143 said in help with aggregate DCI:
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 -
@egert143 said in help with aggregate DCI:
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.2the 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 -
-
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;
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login
Got it working now, many thanks.