adding together OIDs from many different nodes within a tempate?

Started by mgthump, April 01, 2019, 11:59:23 PM

Previous topic - Next topic

mgthump

I'm looking for a way to add up all of the wireless clients connected to an AP, then show this in a dashboard.   the tricky part I can't figure out, is there a way to make this dynamic so as we build our network further, it is automatically sucked into the software?    I've got auto bind setup for an AP template, maybe a way to use the template to build this?


Thanks in advance!

Victor Kirhenshtein

Hi,

depending on what you mean by "add up". Do you want to add each client as a node and collect some data from each? Or you want to count AP clients and calculate some common data on AP?

Best regards,
Victor

mgthump

in the middle of those options.

I'd like our APs to be pulled into a template automatically (I've got that part setup and working) and i have that template collecting the amount of connected Clients from each AP.
Then i'd like a dashboard (or another method inbetween first if needed)  to look at every AP in that template, look at the OID for the number of connected subs and give me the total. 

so  AP 1  has 10 clients,
and AP 2 has 10 more clients skipping to ap 53 all of them with 10 clients each, Id like a dashboard to show me a result of 530 total connected clients across all APs.
I'd like this to happen based on the template container itself if possible so new access points get pulled in automatically.

Thanks!!!!

Victor Kirhenshtein

Hi,

looks like you need DCI summary table. After you hve it configured, you can either open it on demand for any container, or put on dashboard.

Best regards,
Victor

Tursiops

If I understand you correctly, you want a total figure of a specific DCI that exists on all nodes which are assigned to a template.

You could create a dummy node, assign it to the same template and create a separate Script DCI on it, similar to this:

templates = GetNodeTemplates($node);
total=0;
foreach(t : templates) {
if ( t->name == "<NAMEOFYOURTEMPLATE>" ) {
children = GetObjectChildren(t);
foreach(c : children) {
dciValue = GetDCIValue(c,FindDCIByName(c,"<YOUROID>"));
if ( dciValue != null ) total+=dciValue;
}
}
}
return total;


Quite possible that this can be simplified.
I just tested that against a PostgreSQL Template we have, to add up the size of some databases with the same name. I used FindDCIByDescription for this purpose, but the effect will be the same.
Example output (with some additional println to show the individual database sizes to confirm this works):
Database Size: 17988120
Database Size: 1099291160
Database Size: 20306456
Database Size: 49494552
Database Size: 19675672
Database Size: 30808600
Database Size: 16579096


*** FINISHED ***

Result: Total: 1254143656


You can then add this particular script DCI to your Dashboard.

mgthump

This method worked!!!!   I had to use the description as well, but I had been trying to wrap my mind around this stuff for a while.   you and Victor are geniuses.

I've very much a noob with scripting and each little bit I think I grasp a touch more. 

Thanks again, fellas!



Quote from: Tursiops on April 04, 2019, 02:24:29 PM
If I understand you correctly, you want a total figure of a specific DCI that exists on all nodes which are assigned to a template.

You could create a dummy node, assign it to the same template and create a separate Script DCI on it, similar to this:

templates = GetNodeTemplates($node);
total=0;
foreach(t : templates) {
if ( t->name == "<NAMEOFYOURTEMPLATE>" ) {
children = GetObjectChildren(t);
foreach(c : children) {
dciValue = GetDCIValue(c,FindDCIByName(c,"<YOUROID>"));
if ( dciValue != null ) total+=dciValue;
}
}
}
return total;


Quite possible that this can be simplified.
I just tested that against a PostgreSQL Template we have, to add up the size of some databases with the same name. I used FindDCIByDescription for this purpose, but the effect will be the same.
Example output (with some additional println to show the individual database sizes to confirm this works):
Database Size: 17988120
Database Size: 1099291160
Database Size: 20306456
Database Size: 49494552
Database Size: 19675672
Database Size: 30808600
Database Size: 16579096


*** FINISHED ***

Result: Total: 1254143656


You can then add this particular script DCI to your Dashboard.

Victor Kirhenshtein

Actually you can create such script DCI on any node (including server node) and skip GetNodeTemplates part, using FindObject instead. So it will be something like this:

total = 0;
t = FindObject("<NAME_OR_ID_OF_TEMPLATE>");
if (t != 0) {
children = GetObjectChildren(t);
foreach(c : children) {
dciValue = GetDCIValue(c,FindDCIByName(c,"<YOUROID>"));
if ( dciValue != null ) total+=dciValue;
}
}
return total;


With that variant it is not necessary to assign template to node with summary DCI.

Best regards,
Victor

mgthump

Thank you, Victor.   

that example was a touch more flexible.   

great work with NetXMS by the way.  absolute love this program even though I'm still only scratching the surface!