headlines
Query examples
Note: You will notice that PQL queries are written with indentation and capitalization throughout the documentation. This is not a requirement of PQL, but to make them easier to read. In fact, PQL does not require indentation, is not case sensitive, and supports alternative structures.
- Example 1: Simple selection
- Example 2: Simple restriction
- Example 3: More specific restriction
- Example 4: Specific selection
- Example 5: More specific selection
- Example 6: Specific selection with relationship
Query 1: Simple selection
Query 1 asks Paglo to display all the information it has at the device level:
SELECT * FROM /network/device
Since the first item in the SELECT
clause is a * star, this query returns
the entire subtree that matches the search criteria.
The FROM clause references an absolute
path /network/device in the tree.
The results themselves are trees. PQL generates a hitlist in a YAML-like structure that shows relationship structure with one or more indents, sequenced items with dashes, and key value pairs with colons. A scalar value returns itself. Specific subtrees return the sub-trees. Sub-trees are treated like rows in a SQL table.
When run against the sample database, this query finds all 6 devices in the database, and reports all of the corresponding data about each device:
row
*
network
device
system
name 5627
computed_vendor LANIER
computed_model 5627
computed_class printer
computed_score 115
os
version LANIER 5627 5.20
interface
name eth0
mac_address 01:01:02:03:04:05
in_octets 1995335536
out_octets 248342455
oper_status 1
device
system
name ESMITH
computed_vendor Intel
computed_class server
computed_score 10
os
version Linux
interface
name eth0
mac_address 02:A1:A2:A3:A4:A4
in_octets 1229592351
out_octets 1472928781
oper_status 1
interface
nameeth1
mac_address 03:A1:A2:A3:A4:A5
in_octets 0
out_octets 0
oper_status 0
device
system
name AJONES
computed_vendor Intel
computed_class server
computed_score 10
os
version Linux
interface
name eth0
mac_address 04:A1:A2:A3:A4:A8
in_octets 1223098455
out_octets 1523093749
oper_status 1
interface
name eth1
mac_address 05:A1:A2:A3:A4:A9
in_octets 0
out_octets 0
oper_status 0
device
system
computed_model Ethernet Switch
computed_class switch
computed_score 25
os
version Ethernet Switch
interface
name eth0
mac_address 06:13:72:F3:0A:F5
in_octets 0
out_octets 0
oper_status 2
interface
name eth1
mac_address 07:13:72:F3:0A:F6
in_octets 0
out_octets 0
oper_status 2
device
system
name KRYPTON
computed_model Windows Workstation
computed_class workstation
computed_score 125
os
version Darwin Kernel Version 9.2.2
interface
name eth0
mac_address 08:16:CB:FF:FE:66
in_octets 0
out_octets 346
oper_status 1
interface
name eth1
mac_address 09:16:CB:FF:FE:67
in_octets 0
out_octets 0
oper_status 2
interface
name eth2
mac_address 10:16:CB:FF:FE:68
in_octets 0
out_octets 0
oper_status 2
interface
name eth3
mac_address 11:16:CB:FF:FE:69
in_octets 1598233842
out_octets 2360815490
oper_status 1
device
system
name NISSINGETTY
computed_vendor Juniper Networks
computed_model Netscreen Router
computed_class router
computed_score 60
os
version NetScreen-5GT 5.1.043a
interface
name eth0
mac_address 12:10:D8:99:2B:C2
in_octets 1385354750
out_octets 1451321493
oper_status 1
interface
name eth1
mac_address 13:10:D8:99:2B:C1
in_octets 3312952833
out_octets 3239791359
oper_status 1
Query 2: Simple restriction
Query 2 is a more specific variation of
Query 1, using
a WHERE clause to restrict it to find all
the data about the device that has an interface with a
specific MAC address:
SELECT * FROM /network/device WHERE interface/mac_address = '13:10:D8:99:2B:C1'
The query returns a hitlist in the same tree form as earlier, but reports only the data about the router, since it is the only device that has an interface with a matching MAC address. Note that the MAC address limited the results to the device, not to the interface. Thus, the results include one interface with a non-matching MAC address:
row
*
system
name NISSINGETTY
computed_vendor Juniper Networks
computed_model Netscreen Router
computed_class router
computed_score 60
os
version NetScreen-5GT 5.1.043a
interface
name eth0
mac_address 12:10:D8:99:2B:C2
in_octets 1385354750
out_octets 1451321493
oper_status 1
interface
name eth1
mac_address 13:10:D8:99:2B:C1
in_octets 3312952833
out_octets 3239791359
oper_status 1
Query 3: More specific restriction
Instead of selecting everything, as in Query 2, Query 3 asks for information at the interface level:
SELECT interface FROM /network/device WHERE interface/mac_address = '13:10:D8:99:2B:C1'
If run against the sample database, Query 3 returns a hitlist with data about the router's two interfaces:
row
interface
interface
name eth0
mac_address 12:10:D8:99:2B:C2
in_octets 1385354750
out_octets 1451321493
oper_status 1
interface
name eth1
mac_address 13:10:D8:99:2B:C1
in_octets 3312952833
out_octets 3239791359
oper_status 1
Query 4: Specific selection
Query 4 is narrower than Query 1.
It selects only the name and MAC address of interfaces at the
/network/device/interface node:
SELECT mac_address, name FROM /network/device/interface
If run against the sample database, this query generates just the requested information about each interface. In this example, the relationships between the interfaces and the devices that they belong to is not evident:
row mac_address 01:01:02:03:04:05 name eth0 row mac_address 02:A1:A2:A3:A4:A4 name eth0 row mac_address 03:A1:A2:A3:A4:A5 name eth1 row mac_address 04:A1:A2:A3:A4:A8 name eth0 row mac_address 05:A1:A2:A3:A4:A9 name eth1 row mac_address 06:13:72:F3:0A:F5 name eth0 row mac_address 07:13:72:F3:0A:F6 name eth1 row mac_address 08:16:CB:FF:FE:66 name eth0 row mac_address 09:16:CB:FF:FE:67 name eth1 row mac_address 10:16:CB:FF:FE:68 name eth2 row mac_address 11:16:CB:FF:FE:69 name eth3 row mac_address 12:10:D8:99:2B:C2 name eth0 row mac_address 13:10:D8:99:2B:C1 name eth1
Query 5: More specific selection
Unlike Query 4, Query 5 asks for
the same data by making the SELECT clause more specific. This query asks for
the MAC address and name of each interface, from the /network/device
location:
SELECT interface/mac_address, interface/name FROM /network/device
If run against the sample database, this query generates the requested data about each interface. Note that the data is grouped such that the relationships between the interfaces and the devices that they belong to is somewhat evident, but the relationships between each name and each MAC address is not directly evident:
row
interface/mac_address 01:01:02:03:04:05
interface/name eth0
row
interface/mac_address
mac_address 02:A1:A2:A3:A4:A4
mac_address 03:A1:A2:A3:A4:A5
interface/name
nameeth 0
nameeth 1
row
interface/mac_address
mac_address 04:A1:A2:A3:A4:A8
mac_address 05:A1:A2:A3:A4:A9
interface/name
nameeth 0
nameeth 1
row
interface/mac_address
mac_address 06:13:72:F3:0A:F5
mac_address 07:13:72:F3:0A:F6
interface/name
nameeth 0
nameeth 1
row
interface/mac_address
mac_address 08:16:CB:FF:FE:66
mac_address 09:16:CB:FF:FE:67
mac_address 10:16:CB:FF:FE:68
mac_address 11:16:CB:FF:FE:69
interface/name
name eth0
name eth1
name eth2
name eth3
row
interface/mac_address
mac_address 12:10:D8:99:2B:C2
mac_address 13:10:D8:99:2B:C1
interface/name
name eth0
name eth1
Query 6: Specific selection with relationship
By grouping the request for MAC address and name within closed brackets, this query finds the same information as Query 4 and Query 5, but is able to retain the relationships between name and MAC address of each interface, and between interfaces and the devices they are on:
SELECT interface/(mac_address, name) FROM /network/device
If you run this query on the same sample database above, it generates the following results:
row
interface/(mac_address, name)
item
mac_address 01:01:02:03:04:05
name eth0
row
interface/(mac_address, name)
item
mac_address 02:A1:A2:A3:A4:A4
name eth0
item
mac_address 03:A1:A2:A3:A4:A5
name eth1
row
interface/(mac_address, name)
item
mac_address 04:A1:A2:A3:A4:A8
name eth0
item
mac_address 05:A1:A2:A3:A4:A9
name eth1
row
interface/(mac_address, name)
item
mac_address 06:13:72:F3:0A:F5
name eth0
item
mac_address 07:13:72:F3:0A:F6
name eth1
row
interface/(mac_address, name)
item
mac_address 08:16:CB:FF:FE:66
name eth0
item
mac_address 09:16:CB:FF:FE:67
name eth1
item
mac_address 10:16:CB:FF:FE:68
name eth2
item
mac_address 11:16:CB:FF:FE:69
name eth3
row
interface/(mac_address, name)
item
mac_address 12:10:D8:99:2B:C2
name eth0
item
mac_address 13:10:D8:99:2B:C1
name eth1

