Closed Nicolas-SF closed 3 years ago
Hi @Nicolas-SF,
The behavior you are seeing is expected; that is because this is the raw API - literally what is scraped from the Settings page of the object. If you want to access a more coherent representation of the Interval
property, you can get it by simply doing Get-ObjectProperty
without the -Raw
, or just grab it from the Sensor
in the first place (since Sensor
objects also have this property)
(Get-Sensor -Id 1003).Interval
Regards, lordmilko
Thanks for your quick reply lordmilko, but there is something really weird! :) When grabbing info, i always catch a 1m interval... `PS C:\Users\nicol> (Get-Sensor -Id 1003).Interval
Days : 0 Hours : 0 Minutes : 1 Seconds : 0 Milliseconds : 0 Ticks : 600000000 TotalDays : 0,000694444444444444 TotalHours : 0,0166666666666667 TotalMinutes : 1 TotalSeconds : 60 TotalMilliseconds : 60000`
`PS C:\Users\nicol> Get-Sensor -id 1003 | Get-ObjectProperty
InheritAccess : True ParentTags : DebugMode : Url : HttpRequestMethod : PostData : UseCustomPostContent : PostContentType : UseSNIFromUrl : Timeout : PingPacketSize : PingMode : PingCount : PingDelay : AutoAcknowledge : GraphType : Independent ExeFile : ExeParameters : SetExeEnvironmentVariables : UseWindowsAuthentication : Mutex : WmiMode : Target : PingRemotePacketSize : ChannelDefinition : FactoryErrorMode : FactoryErrorFormula : FactoryMissingDataMode : StartStopped : NotifyChanged : MonitorPerformance : ServiceName : Database : UseCustomInstance : InstanceName : SqlEncryptionMode : UseSqlInputParameter : SqlInputParameter : SqlTransactionMode : Name : Probe Health Tags : {probehealthsensor} Priority : Five InheritProxy : ProxyAddress : ProxyPort : ProxyUser : HasProxyPassword : False InheritInterval : True Interval : 00:01:00 IntervalErrorMode : OneWarningThenDown InheritDependency : Schedule : MaintenanceEnabled : MaintenanceStart : MaintenanceEnd : DependencyType : DependentObjectId : DependencyDelay : InheritChannelUnit : True BandwidthVolumeUnit : BandwidthSpeedUnit : BandwidthTimeUnit : MemoryUsageUnit : MByte DiskSizeUnit : MByte FileSizeUnit : `
But it's not true.... Nothing set on the setting tab of this object, interval is inherited from the root...
I think i got something: when i cut the inheritance, 60s is what is set by default in the field. I can change it to 5m, save. Then I force the inheritance again, and then i got my 5 minutes through my request. It's like the property catched is the one deep in the object, behind the inheritance, even if we want this inheritance...
Hi @Nicolas-SF,
When you do
(Get-Sensor -Id 1003).Interval
this shows you the effective interval of the object, whether it is inherited or not.
When you do (Get-Sensor -Id 1003 | Get-ObjectProperty).Interval
this shows you the interval that is specified on the Settings page of the object. Even if inheritance is enabled, the interval it would use when inheritance was disabled is still contained in the page
If you were to disable inheritance by clicking the button, you would see that 60s is now selected
As such, you should always get the Interval
straight from the Sensor
object - that is the true effective interval that is in effect
I got your point lordmilko, but i assure you that i only grab the real object property, and not the effective one... Even through straight from the sensor object... That's the real issue here. I've double check, and i can't grab the working interval when it's inherited.
I've checked on other prtg platforms and still the same behaviour. Interval shown is always the one stored in the object, not the active one. :/
Hi @Nicolas-SF,
After doing some testing it appears you are in fact correct! When you set the Interval of a parent device to 5 minutes, and set the Interval of a sensor under it to 60 seconds, the sensor correctly reports is interval is 60 seconds. However if you then disable inheritance on the sensor, the interval is still reported as 60 seconds when it should in fact be 5 minutes.
This appears to be an issue with the PRTG API, dating at least all the way back to version 14.4. You can see in the API response that it knows that the sensor has an inherited value of 300 seconds (5 minutes), however in the numeric value (which is what PrtgAPI uses) it displays 60 seconds
<intervalx>Inherited (300)</intervalx>
<intervalx_raw>0000000060</intervalx_raw>
As a workaround, to get the true interval of an object you can potentially traverse the object's ancestral hierarchy until you find the object that actually defines the interval
function Get-TrueInterval
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, ValueFromPipeline = $true)]
[object]$Object
)
if($Object.InheritInterval)
{
return (Get-Object -Id $Object.ParentId -Resolve | Get-TrueInterval)
}
else
{
return $Object.Interval
}
}
Get-Sensor -Id 1003 | Get-TrueInterval
Objects found by auto-discovery generally tend to have explicitly set intervals defined on them; for sensors I create manually, I usually do this with PrtgAPI and mass-configure the interval to use with Set-ObjectProperty
, also resulting in intervals defined on the object
Ok! Thanks for the tip with this function. ;)
Good job, keep going on!
Hi @Nicolas-SF,
Please be advised PrtgAPI 0.9.15 has now been released which includes a fix for this issue
To update PrtgAPI, please run Update-Module PrtgAPI
and reopen PowerShell
Regards, lordmilko
Hi,
Here is something apparently going wrong with the prtgapi: whn getting raw details of an object, the interval seems not the good one... Any idea about this behaviour? Seen this before?
Thanks!