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
- Supported Object Types for pause.htm
- Error Handling, Rescanning
- Rescanning, Triggering Auto-Discovery
- Reordering Objects in the Sensor Tree
- 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:
Set priority of an object (valid values for x are 1 to 5):
Change properties of objects:
This function can change most string and number properties of objects (names, numeric values, object identifiers (OID), etc.). Use it with caution. You can discern the property_name parameter by opening the Settings page of an object and looking at the HTML source of the INPUT fields. For example, the INPUT field for the tags of an object has the name tags_. Leave away the underscore _ and use tags as a value for the property_name parameter.
Supported Object Types for rename.htm
rename.htm supports the following object types:
- notification template
- 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:
This internal name must be followed by an underscore (_), in contrast to changing properties above. Use the value 0 for switching off inheritance, and 1 for switching on inheritance. For example, the inheritance type for the scanning interval setting has the name intervalgroup_. Thus, this specific part in the URL is &name=intervalgroup_&value=0 (switches off inheritance for scanning interval).
This call does not work with the Schedules, Dependencies, and Maintenance Window settings.
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).
Example: Enabling and Setting Limits for Channels
Set limits for channels:
You must set the limits for a channel before you can enable limits.
Enable limits for channels:
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.
For Toplists, you can use the subtype toplist to change the properties. When using this subtype, subid is the ID of a Toplist.
For a list of available channel parameters, see section Single Object Property.
Pause a sensor or object indefinitely:
Pause a sensor or object for x minutes:
The pause message is optional. You can leave out the parameter &pausemsg=yourmessage if you do not want to display a message.
Simulate an error for a sensor:
simulate.htm only works for sensors in the Up, Warning, Unusual, or Unknown status.
Resume monitoring of a sensor or object:
Supported Object Types for pause.htm
pause.htm supports the following object types:
- user account
pause.htm does not support other object types.
Error Handling (Acknowledge Alarm)
Acknowledge the Down status:
Rescanning, Triggering Auto-Discovery
Scan a sensor now:
Run an auto-discovery for a group or device:
Providing a device template for auto-discovery is optional. You can leave out the parameter &template=filename to run the auto-discovery with the options defined in the object's settings. If you use a template, provide the whole file name including file extension surrounded by double quotation marks (") and encode whitespaces, if necessary. Example: &template="Linux%20SNMP.odt"
discovernow.htm overrides the Auto-Discovery setting of the target group or device. If it is set to No auto-discovery, it automatically changes to Standard auto-discovery (recommended).
Reordering Objects in the Sensor Tree
Move an object in the sensor tree (x can be up, down, top, bottom):
Add a group, device, or sensor to a report:
Trigger a notification immediately for testing purposes:
objectid is the ID of the notification template.
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.
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:
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:
- notification template
duplicateobject.htm does not support other object types.
Duplicate a group:
Duplicate a device:
Duplicate a sensor:
Duplicate a library:
Duplicate a notification template:
If duplicateobject succeeds, the PRTG core server replies with a redirect to the URL of the new object (for example, /sensor.htm?id=1234), so your application should parse the new object ID from this URL.
When a group, device, or sensor is cloned, it is initially set to Paused so you have the chance to edit parameters as desired. You must resume it with an API call afterward.
The API calls for duplicating reports, maps, libraries, and notification templates do not require a targetid.
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):
Rename the new sensor:
Change the OID (in this example for an SNMP Custom sensor):
Resume monitoring for the new sensor:
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:
How can I use the PRTG Application Programming Interface (API)?