Hi,

I would like modify channels settings after cloned a combined sensor by API.

For exemple I have this parameters on the initial sensor in the 'Channel definition' part :

  1. 2:Trafic entrant Channel(6456,0)+Channel(6458,0)
  2. 3:Trafic sortant Channel(6456,1)+Channel(6458,1)
  3. 4:Debit maximum [Kbit/s] 20000
  4. 1:Trafic entrant (canal principal) Channel(6456,0)+Channel(6458,0)
  5. 5:Utilisation trafic entrant percent(Channel(6456,0)+Channel(6458,0),20000,kilobit)
  6. 6:Utilisation trafic sortant percent(Channel(6456,1)+Channel(6458,1),20000,kilobit)

And i would like modify id of sensor (ex : 6456 to 7099) and the speed (ex : 20000 to 10000)

Its possible, what is the request ?

Thanks for your help! Thibaut.


Article Comments

Sorry to formating, i can't edit previous post :

parameters on the initial sensor in the 'Channel definition' part :

#2:Trafic entrant 
Channel(6456,0)+Channel(6458,0)
#3:Trafic sortant 
Channel(6456,1)+Channel(6458,1)
4:Debit maximum [Kbit/s] 
20000
#1:Trafic entrant (canal principal) 
Channel(6456,0)+Channel(6458,0)
#5:Utilisation trafic entrant percent
(Channel(6456,0)+Channel(6458,0),20000,kilobit)
#6:Utilisation trafic sortant percent
(Channel(6456,1)+Channel(6458,1),20000,kilobit)

Sep, 2020 - Permalink

Hello,

Thank you for your message.

To modify the channel definition of the Sensor Factory sensor, I invite you to take a look at the PowerShell module called PRTGAPI.

With this module, you are able to get the properties of a sensor by using the command Get-Sensor -id {id} | Get-ObjectProperty.

Therefore you can get the channel definition of the SF sensor by using the command above, replace the values you want and then, use the command Set-ObjectProperty to apply the modification.

The commands are described in the wiki of the PowerShell module whose GitHub page is here: https://github.com/lordmilko/PrtgAPI

There is also a wiki which is very well documented: https://github.com/lordmilko/PrtgAPI/wiki

Kind regards.


Sep, 2020 - Permalink

Thanks for your answer.

my script is based on Python. What is the API call url if existing ?


Sep, 2020 - Permalink

Hi Th1b0plz,

In addition to the above, I would recommend you check out the Sensor Factories page, which not only includes an example of how you would modify a sensor factory channel definition using Set-ObjectProperty, but also how you can dynamically generate complex sensor factory definitions based on a collection of sensors. This may be useful for automatically updating your channel definitions based on changing requirements going forward.

If you wish to utilize the raw HTTP API to perform this instead, you can view the API request that PrtgAPI generates by specifying the -Verbose parameter to Set-ObjectProperty. Note however that given the complex URL encoding involved doing it manually with the raw API may not be desirable.

Regards,

lordmilko


Sep, 2020 - Permalink

The following demonstrates the API request you would use to set the channel definition

#1:Channel
channel(2059,0)

on the object with ID 1001

http://prtg.example.com/editsettings?id=1001&aggregationchannel_=%231%3AChannel%0Achannel(2059%2C0)&username=prtgadmin&passhash=12345678

Sep, 2020 - Permalink

Its works perfectly !

just in python must add a '%' before another '%' else python is interpreting the % as a printf-like format character

Thanks you very much !

Edit : i'm stupid sorry.. i guess it must just write all settings in the same url


Sep, 2020 - Permalink

Hello,

I've an annoter question about this subject

And how can i just add settings at the existant ? Because this API call works fin to write a channel settings but it erase existants


Sep, 2020 - Permalink

Hi Th1b0plz,

I'm not too sure I understand what you're asking, but in order to update the sensor factory channel definition you need to rewrite the entire definition. As such, if you want to make any changes to it, you need to request the entire definition from PRTG, make your changes to it, and then reapply the updated definition to PRTG


Sep, 2020 - Permalink