Thanks for the update Torsten.
For anyone else who comes across this post in the same problem, the best workaround I've found is to delete the sensors and recreate from template. You lose all your historic data.
Here's my hacked together powershell code for reference / save someone else the time:
$devices = PRTG_Get_Devices | ?{$_.device -like "*windows*"}
$template_sensor_id = 3832 # Memory sensor
PRTG_Duplicate_Sensors -devices $devices -template_sensor_id $template_sensor_id
########## DUPLICATE TEMPLATE SENSOR TO ARRAY OF DEVICES
Function PRTG_Duplicate_Sensors
{
param ($devices,$template_sensor_id)
#$template_sensor_id = 3744
$template_sensor = PRTG_Get_Sensors | ?{$_.objID -eq $template_sensor_id}
foreach ($device in $devices)
{
$existing_sensor = $null
$existing_sensor = PRTG_Get_Sensors | ?{$_.device -eq $device.device} | ?{$_.sensor -eq $template_sensor.sensor}
if (($existing_sensor -ne $null) -and ($device.device -ne $null))
{
"Sensor already exists on "+($device.device)+" - removing"
$url = $prtg_api+"deleteobject.htm?id="+$existing_sensor.objid+"&approve=1"+$userstring
$text = (new-object system.net.webclient).downloadstring($url)
}
if ($device.device -ne $null)
{
"Sensor doesn't exist on "+$device.device+", creating sensor"
$url = $prtg_api+"duplicateobject.htm?id="+$template_sensor_id+"&name="+$template_sensor.sensor+"&targetid="+$device.objid+$userstring
$text = (new-object system.net.webclient).downloadstring($url)
$text = $text.Substring(($text.IndexOf('/sensor.htm?id=')),19)
$new_sensor_id = $text.Substring(($text.IndexOf('=')+1),4)
# Start the senor
$url = $prtg_api+"pause.htm?id="+$new_sensor_id+"+&action=1"+$userstring
$text = PRTG_Get($url)
# Run a scan
$url = $prtg_api+"scannow.htm?id="+$new_sensor_id+$userstring
$out = PRTG_Get($url)
}
else
{"device can't be found"}
}
}
Function PRTG_Get
{
param ([String]$url)
#$url = $prtg_api+"table.xml?content=sensors&columns=objid,group,device,sensor,status,message,lastvalue,priority,favorite"+$userstring
$text = (new-object system.net.webclient).downloadstring($url)
$text2 = $text.Replace("", "")
$output=[xml]$text2
$output
}
Function PRTG_Get_Sensors
{
$url = $prtg_api+$url_sensor+$userstring
(PRTG_Get($url)).sensors.item
}
Add comment