New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Count all child elements 1 level deep

Votes:

0

Your Vote:

Up

Down

Is it possible to count all the child elements directly under an icon? All types of child elements should be considered (devices and groups).

customize maps status-icons

Created on Apr 13, 2015 11:42:15 AM by  JJStr (0) 1



2 Replies

Accepted Answer

Votes:

3

Your Vote:

Up

Down

I guess your best starting point is the table.xml API call

http://yourserver/api/table.xml?content=sensortree&username=myuser&password=mypassword

You can limit the result set by including the objectID of the parent 'icon'

http://yourserver/api/table.xml?content=sensortree&id=1234&username=myuser&password=mypassword

'Feeding' the url above to the HTTP XML/Rest Value Sensor using XPath query sensortree/nodes/*[1] and selecting Count Child Nodes will give you the number of child elements +7

The +7 is caused by the additional describing nodes (<name>,<id>,<url>,...) in the xml result.

You might be able to filter out these additional nodes using a more advanced XPath query.

Created on Apr 13, 2015 3:13:29 PM by  PRTG Tools Family [prtgtoolsfamily.com] (12,885) 3 4



Votes:

0

Your Vote:

Up

Down

Thanks for your response.

However with this approach, we have to create an additional sensor for the counting on each of the affected groups and we lose the status color of the group on the icon.

Based on your suggestions, I have implemented this using jQuery code in the icon template:

<span id="count<@objectid>"/>

<script>
  $(document).ready(function(){
    $.get("https://yourserver/api/table.xml?content=sensortree&id=<@objectid>", function(data) {
      $('#count<@objectid>').text($('sensortree > nodes > :first-child > :has(*)', data).length);
    });
  });
</script>

Created on Apr 16, 2015 4:36:20 PM by  JJStr (0) 1

Last change on Apr 16, 2015 6:36:31 PM by  Torsten Lindner [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.