headlines
PQL num_children() function
num_children() — Counts the number of child nodes of a parent node.
Syntax
The num_children() function returns
a tree and takes a tree parameter:
tree num_children(tree input)
Return value
The num_children() function returns a tree.
Description
The num_children() function finds
the number of child nodes of a parent node. The num_children() function takes
1 parameter.
Examples
- Example 1: Count interface children
- Example 2: Count children of Directory item properties
- Example 3: Count children of systems with low disk space
Example 1: Count interface children
Query: How many children does each interface have?
SELECT num_children(interface) FROM /network/device
Results: Depending on the database, this query returns results similar to this:
row num_children(interface)5 row num_children(interface)26 row num_children(interface)2 row num_children(interface)174 . . .
Example 2: Count children of Directory item properties
Query: How many children do the Directory Items properties have?
SELECT properties/name, num_children(properties) FROM /directory/item
Results: Depending on the database, this query returns results similar to this:
row /properties/name VOLANS num_children(properties) 20 row /properties/name EARTH num_children(properties) 15 row /properties/name JUPITER num_children(properties) 16 row /properties/name GRUS num_children(properties) 21 . . .
Example 3: Children of systems with low disk space
Query: How many child nodes do the systems with low disk space have?
SELECT num_children(systemname) FROM %free disk space% WHERE freespace < 1000000000 AND description = 'Local Fixed Disk'
Results: Depending on the database, this query returns results similar to this:
row has_history(systemname) 0 row has_history(systemname) 0 row has_history(systemname) 0
To see other PQL functions, see Functions.

