PRTG Manual: Object Manipulation
You can use the following functions to manipulate objects (URLs are shown without user name or passhash to enhance readability).
In this section:
- Changing Object Settings
- Supported Object Types for rename.htm
- Switch Inheritance Off/On
- Changing Properties of Channels
- Pausing/Resuming
- Supported Object Types for pause.htm
- Error Handling
- Rescanning, Triggering Auto-Discovery
- Reordering Objects in the Sensor Tree
- Report-related
- Notification-related
- Adding/Deleting Objects
- Supported Object Types for duplicateobject.htm
- Duplicating Sensors and Changing Clone Settings
- Setting Geo Location
Authentication with API key or user name and passhash (or user name and password) must always be included in each PRTG API request. See section HTTP API for more information.
Rename an object: /api/rename.htm?id=objectid&value=newname Set priority of an object (valid values for x are 1 to 5): /api/setpriority.htm?id=objectid&prio=x Change properties of objects: /api/setobjectproperty.htm?id=id_of_object&name=property_name&value=new_value
|
Supported Object Types for rename.htm
rename.htm supports the following object types:
- group
- device
- sensor
- map
- report
- library
- notification template
- schedule
- user
- user group
rename.htm does not support other object types.
This API call sets the inherit setting of objects (location, credentials, compatibility options, proxy settings, scanning interval, access rights, channel unit). In general, this works like changing properties for any other object.
Replace the parameter inheritType with the name of the inheritance type: /api/setobjectproperty.htm?id=id_of_object&name=inheritType_&value=0_or_1
|
Changing Properties of Channels
With this API call, you can change a sensor's channel settings. In general, this works like changing properties of any other object. To set channel properties via the PRTG API, you need to provide
- the ID of a sensor (parameter id),
- a subtype (channel for channels), and
- a subid (ID of the channel that you want to edit).
Set limits for channels: /api/setobjectproperty.htm?id=sensorid&subtype=channel&subid=0&name=limitmaxerror&value=limitvalue
Enable limits for channels: /api/setobjectproperty.htm?id=sensorid&subtype=channel&subid=0&name=limitmode&value=1 For example, the following API call sets the upper error limit of a channel with the ID 0 of a sensor with the ID 2970 to the value 25. /api/setobjectproperty.htm?id=2970&subtype=channel&subid=0&name=limitmaxerror&value=25
|
For a list of available channel parameters, see section Single Object Property.
Pause a sensor or object indefinitely: /api/pause.htm?id=objectid&pausemsg=yourmessage&action=0 Pause a sensor or object for x minutes: /api/pauseobjectfor.htm?id=objectid&pausemsg=yourmessage&duration=x
Simulate an error for a sensor: /api/simulate.htm?id=objectid&action=1
Resume monitoring of a sensor or object: /api/pause.htm?id=objectid&action=1 |
Supported Object Types for pause.htm
pause.htm supports the following object types:
- probe
- group
- device
- sensor
- notification
- user account
pause.htm does not support other object types.
Error Handling (Acknowledge Alarm)
Acknowledge the Down status: /api/acknowledgealarm.htm?id=objectid&ackmsg=yourmessage |
Rescanning, Triggering Auto-Discovery
Scan a sensor now: /api/scannow.htm?id=objectid Run an auto-discovery for a group or device: /api/discovernow.htm?id=objectid&template=filename
|
Reordering Objects in the Sensor Tree
Move an object in the sensor tree (x can be up, down, top, bottom): /api/setposition.htm?id=objectid&newpos=x |
Add a group, device, or sensor to a report: /api/reportaddsensor.htm?id=reportid&addid=objectid |
Trigger a notification immediately for testing purposes: /api/notificationtest.htm?id=objectid /api/notificationtest.json?id=objectid
|
Adding and deleting objects in your configuration is the most complex and potentially most critical process when using the PRTG API. Keep in mind that adding or deleting objects is much better guided in the normal PRTG web interface with more warnings and alerts.
We recommend that you use the PRTG web interface for adding and deleting objects, if possible.
Deleting Objects
API calls to the delete function immediately delete the referenced object including all subobjects, if there are any. For example, deleting a group deletes all its devices and sensors. There is no way to undo a deletion, so use this function with care.
Delete an object: /api/deleteobject.htm?id=objectid&approve=1 |
Adding Objects
Adding completely new objects from scratch is not supported via the PRTG API because of the complexity of object creation and its parameters. To add new objects to PRTG, create a "master" object that is cloned into new objects.
Supported Object Types for duplicateobject.htm
duplicateobject.htm supports the following object types:
- group
- device
- sensor
- report
- library
- map
- notification template
duplicateobject.htm does not support other object types.
Duplicate a group: /api/duplicateobject.htm?id=id_of_group_to_clone&name=new_name&targetid=id_of_target_group Duplicate a device: /api/duplicateobject.htm?id=id_of_device_to_clone&name=new_name&host=new_hostname_or_ip&targetid=id_of_target_group Duplicate a sensor: /api/duplicateobject.htm?id=id_of_sensor_to_clone&name=new_name&targetid=id_of_target_device Duplicate a library: /api/duplicateobject.htm?id=id_of_library_to_clone&name=new_name Duplicate a notification template: /api/duplicateobject.htm?id=id_of_notification_template_to_clone&name=new_name
|
Duplicating Sensors and Changing Clone Settings
The following process duplicates a sensor, changes some settings, and then starts monitoring:
Duplicate the sensor (the server replies with a redirect to the new object's web page, for example /sensor.htm?id=10214, parse id 10214 from the URL): /api/duplicateobject.htm?id=2002&name=mynewsensor&targetid=2001 Rename the new sensor: /api/setobjectproperty.htm?id=10214&name=name&value=newname Change the OID (in this example for an SNMP Custom sensor): /api/setobjectproperty.htm?id=10214&name=oid&value=1.2.3.4.5.6.7 Resume monitoring for the new sensor: /api/pause.htm?id=10214&action=1 |
You can set the location of any object via an API call. Provide the object ID together with parameters for location and/or longitude and latitude.
If only the location parameter is specified, the PRTG core server executes the geo location lookup (this can take up to three minutes). Provide the name of the location, for example, New York. It is shown in the Location settings, no matter the longitude or latitude.
If the longitude and latitude parameter is specified, the marker in the map is set to this position, no matter of the location parameter. Provide longitude and latitude separated by a comma, for example -73.998672,40.714728.
Set the geo location of an object: /api/setlonlat.htm?id=objectid&location=name_of_object_location&lonlat=longitude,latitude |
KNOWLEDGE BASE
How can I use the PRTG Application Programming Interface (API)?