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


I need a boolean answer to an API query to determine if a device ID is valid.

Votes:

0

Your Vote:

Up

Down

Hello,

Using: http://yourserver/api/table.xml?content=sensortree&id=7788 I can retrieve exactly what I need to determine the ID of available sensors for a specific device.

I can not find a method that returns a simple "device not found" when supplied an invalid device id.

Ideally http://yourserver/api/table.xml?content=sensortree&id=bogus_id would return that.

Is there a simple, fast, supported way to do this?

api prtg query

Created on Jul 21, 2011 2:17:31 PM by  nuzzio (0) 1



3 Replies

Accepted Answer

Votes:

0

Your Vote:

Up

Down

Try the GetObjectsproperty function:

/api/getobjectproperty.htm?id=12345678

The reply is

<?xml version="1.0" encoding="UTF-8" ?> 
<prtg> 
<version>8.4.2.2381</version> 
<error>Sorry, the selected object cannot be used here or it does not exist.</error> 
</prtg>

Created on Jul 22, 2011 9:54:40 AM by  Dirk Paessler [Founder Paessler AG] (10,921) 3 4



Votes:

0

Your Vote:

Up

Down

Always check the ResponseUri from your request.

This will give you the "device not found" and other errors that might occur.

Created on Jul 22, 2011 10:05:51 AM by  PRTG Tools Family [prtgtoolsfamily.com] (13,163) 3 4



Votes:

0

Your Vote:

Up

Down

@Gerard Feijth - sadly that information does not appear in the return headers or return url for these particular requests (using cURL and php).

@Dirk Paessler - This works perfectly and is very fast, thank you.

Is it safer to use the strings:

'Sorry, the selected object cannot be used here or it does not exist.' === does not exist

and

'(Property not found)' === does exist

or do you recommend simply check against the existence of the <error> and <result> tags?

Created on Jul 22, 2011 3:20:29 PM by  nuzzio (0) 1



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.