Find an Answer
PQL supports both qualified and unqualified paths. A qualified path is a path that is restricted with the conditions, such as:
interface[name='eth0']. An unqualified path, or simple path, contains no conditions, such as: interface/name.
You can try the following examples against your own data in the GoToAssist search field, or against fictitious data in the Query Sandbox:
This query fetches all known information about the interface named eth0 that has the MAC address of 12:10:D8:99:2B:C2:
SELECT interface FROM /network/device WHERE interface/name = 'eth0' AND interface/mac_address = '12:10:D8:99:2B:C2'
When run against the sample database, this query displays all the information about the specified interface:
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
This example query finds the operating status of a specific interface:
SELECT interface[name = 'eth0']/oper_status FROM /network/device WHERE interface[name = 'eth0']/mac_address = '12:10:D8:99:2B:C2'
When run against the sample database, this query displays the operating status of the specified interface:
row
interface/oper_status
oper_status 1
A more useful query might be one that returns all the data that's known about the interface node, like this:
SELECT interface FROM /network/device WHERE interface[name = 'eth0']/mac_address = '12:10:D8:99:2B:C2'
This query lists all the data about the specified interface, including the oeprating status:
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
Note how this query returned both interfaces from the device, even though the WHERE clause used a specific interface to find the device. The next example is probably more useful.
You can narrow the query so that it returns nothing but the name of a single interface, like this:
SELECT interface[mac_address='12:10:D8:99:2B:C2']/name FROM /network/device WHERE interface/mac_address='12:10:D8:99:2B:C2'
This query returns only the name of the one interface that has a matching MAC address of '01:01:02:03:04:05':
row interface[mac_address = 12:10:D8:99:2B:C2]/name eth0
This query uses a qualified path that limits the results to a specific subnet. To use this against your own GoToAssist account, adjust the IP addresses.
SELECT nvl(system/name, system/dns_name) as "Name", nvl(system/model, system/class, wmi/win32_computersystem/domainrole) as "Type", interface[inet/ip_address like '1.1.1.']/inet/ip_address as "IP Address", last_seen from /network/device WHERE system is not null AND interface/inet/ip_address like '1.1.1.'
Depending on the database, this query returns results that work well in a table, like this:
row
Name cannes-server.acme.local
Type null
IP Address 1.1.1.1
last_seen 2008-04-17T00:02:01.0000000Z
row
Name HP ProCurve
Type HP J4093A ProCurve Switch 2424M,
revision C.09.19, ROM C.06.01
(/sw/code/build/vgro(c09))
IP Address
ip_address 1.1.1.2
ip_address 1.1.1.2
last_seen 2008-04-17T01:06:25.0000000Z
row
Name amsterdam.acme.local hq.acme.com
Type null
IP Address 1.1.1.3
last_seen 2008-04-15T17:31:32.0000000Z
row
Name berne-server.acme.local
Type 1 Member Workstation
IP Address 1.1.1.4
last_seen 2008-04-17T00:04:37.0000000Z
. . .
Related topics