Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-SensorHistory > Input string was not in a correct format #221

Closed
2 tasks done
schoenm1 opened this issue May 28, 2021 · 30 comments
Closed
2 tasks done

Get-SensorHistory > Input string was not in a correct format #221

schoenm1 opened this issue May 28, 2021 · 30 comments
Labels
bug Issues that have been confirmed to be bugs in PrtgAPI and will be fixed in a future version

Comments

@schoenm1
Copy link

My enviroment: I have some EXEXML Sensors. These Sensors are reporting a number and the execution time of most .ps1 files are <60 Seconds. But one Sensor execution time is between 60-120 seconds. (I think this could be the issue)

For every sensor, the "Get-SensorHistory" is working, except for the exe Sensor (long execution time).
For this sensor to work, I needed to increase the Timeout (sec) from the default value of 60 seconds.

All other Sensors:

PS C:\Users\user> Get-Sensor -id 81053 | Get-SensorHistory -end $enddate -start $startdate 
DateTime            SensorId MMA-Option:CUST-ALERT(#) Coverage(%)
--------            -------- ------------------------ -----------
28.05.2021 08:24:26 81053    644                      100
28.05.2021 07:24:01 81053    644                      100
28.05.2021 03:24:01 81053    644                      100
[...]
PS C:\Users\user> Get-Sensor -id 81082 | Get-SensorHistory -end $enddate -start $startdate
Get-SensorHistory : Input string was not in a correct format.
At line:1 char:24
+ ... -Sensor -id 81082 | Get-SensorHistory -end $enddate -start $startdate
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-SensorHistory], FormatException
    + FullyQualifiedErrorId : System.FormatException,PrtgAPI.PowerShell.Cmdlets.GetSensorHistory

With an average argument, I can get a return value. But I want the raw data, no average.

PS C:\Users\user> Get-Sensor -id 81082 | Get-SensorHistory -end $enddate -start $startdate -average 300

DateTime            SensorId MMA-Option:CRW(#) Downtime(%) Coverage(%)
--------            -------- ----------------- ----------- -----------
28.05.2021 09:20:00 81082                      0           0
28.05.2021 09:15:00 81082                      0           0
28.05.2021 09:10:00 81082                      0           0

Is there a possiblity to wait longer for a reply?
I think the exection time could be the problem but I don't understand, why a "Get-SEnsorHistory" should be related to the Sensor execution time. But all other parameters are the same as the other working sensors.

Due Dilligance
Please enter an 'x' between the brackets to indicate you have done these

  • It wasn't covered by the wiki, I swear!
  • I have tried doing some basic research on this issue but haven't been able to come up with anything. Please help!
@schoenm1 schoenm1 added the question Questions raised by people who don't know how to program or read the wiki :P label May 28, 2021
@lordmilko
Copy link
Owner

lordmilko commented May 28, 2021

Hi @schoenm1,

I don't think the sensor scanning interval is related to this issue; it appears that some historical info on this sensor is in some sort of format that Get-SensorHistory doesn't know how to deal with

Can you please do

Set-PrtgClient -LogLevel Response
Get-Sensor -id 81082 | Get-SensorHistory -end $enddate -start $startdate -Verbose

And provide the XML response?

Also, when you get the exception what is the output of $error[0].Exception.StackTrace?

@schoenm1
Copy link
Author

PS C:\Users\user> Set-PrtgClient -LogLevel Response
PS C:\Users\user> Get-Sensor -id 81082 | Get-SensorHistory -end $enddate -start $startdate -Verbose
VERBOSE: Get-SensorHistory: <?xml version="1.0" encoding="UTF-8"?>
  <histdata totalcount="7" listend="0">
   <prtg-version>21.1.66.1664</prtg-version>
  </histdata>
VERBOSE: Get-SensorHistory: <?xml version="1.0" encoding="UTF-8"?>
  <histdata totalcount="7" listend="1">
   <prtg-version>21.1.66.1664</prtg-version>
   <item>
    <datetime>28.05.2021 08:48:46</datetime>
    <datetime_raw>44344.2838735764</datetime_raw>
    <value channel="MMA-Option:CRW" channelid="2">8&apos;544 #</value>
    <value_raw channel="MMA-Option:CRW" channelid="2">8544.0000</value_raw>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
   </item>
   <item>
    <datetime>28.05.2021 08:43:50</datetime>
    <datetime_raw>44344.2804501389</datetime_raw>
    <value channel="MMA-Option:CRW" channelid="2">8&apos;544 #</value>
    <value_raw channel="MMA-Option:CRW" channelid="2">8544.0000</value_raw>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
   </item>
   <item>
    <datetime>28.05.2021 08:38:49</datetime>
    <datetime_raw>44344.2769662500</datetime_raw>
    <value channel="MMA-Option:CRW" channelid="2">8&apos;544 #</value>
    <value_raw channel="MMA-Option:CRW" channelid="2">8544.0000</value_raw>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
   </item>
   <item>
    <datetime>28.05.2021 08:34:37</datetime>
    <datetime_raw>44344.2740471759</datetime_raw>
    <value channel="MMA-Option:CRW" channelid="2">8&apos;544 #</value>
    <value_raw channel="MMA-Option:CRW" channelid="2">8544.0000</value_raw>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
   </item>
   <item>
    <datetime>28.05.2021 08:25:51</datetime>
    <datetime_raw>44344.2679558449</datetime_raw>
    <value channel="MMA-Option:CRW" channelid="2">8&apos;544 #</value>
    <value_raw channel="MMA-Option:CRW" channelid="2">8544.0000</value_raw>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
   </item>
   <item>
    <datetime>28.05.2021 08:21:44</datetime>
    <datetime_raw>44344.2650930324</datetime_raw>
    <value channel="MMA-Option:CRW" channelid="2"/>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
   </item>
   <item>
    <datetime>28.05.2021 08:20:43</datetime>
    <datetime_raw>44344.2643897106</datetime_raw>
    <value channel="MMA-Option:CRW" channelid="2"/>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
   </item>
  </histdata>
Get-SensorHistory : Input string was not in a correct format.
At line:1 char:24
+ ... -id 81082 | Get-SensorHistory -end $enddate -start $startdate -Verbos ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-SensorHistory], FormatException
    + FullyQualifiedErrorId : System.FormatException,PrtgAPI.PowerShell.Cmdlets.GetSensorHistory

PS C:\Users\user>

@lordmilko
Copy link
Owner

Thanks @schoenm1,

In addition, after you generate the exception can you provide the output of $error[0].Exception.StackTrace

@schoenm1
Copy link
Author

PS C:\Users\user> $error[0].Exception.StackTrace
   at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
   at PrtgAPI.Utilities.ConvertUtilities.ToDynamicDouble(String str, Nullable`1 raw)
   at PrtgAPI.PowerShell.SensorHistoryFormatter.GetChannelValue(ChannelHistoryRecord channel)
   at PrtgAPI.PowerShell.SensorHistoryFormatter.CreateObject(SensorHistoryRecord date)
   at PrtgAPI.PowerShell.SensorHistoryFormatter.<Init>d__10.MoveNext()
   at PrtgAPI.PowerShell.SensorHistoryFormatter.<Format>d__9.MoveNext()
   at PrtgAPI.PowerShell.Base.PrtgProgressCmdlet.WriteList[T](IEnumerable`1 sendToPipeline)
   at PrtgAPI.PowerShell.Cmdlets.GetSensorHistory.ProcessRecordEx()
   at PrtgAPI.PowerShell.Base.PrtgCmdlet.ExecuteWithCoreState(Action action)
   at System.Management.Automation.CommandProcessor.ProcessRecord()

@lordmilko
Copy link
Owner

lordmilko commented May 28, 2021

Hi @schoenm1,

To give some context before getting into the issue

  • Get-SensorHistory tries to be "clever" and present you a magical view of your data in a way that can easily be mathematically operated on, allowing you to do funky things like Get-SensorHistory -Id 1001 | where MemoryFree -gt 100. In order to facilitate this however, the values emitted by Get-SensorHistory need to be numerical values
  • PRTG returns numerical values in the value_raw field of the XML response, however Get-SensorHistory can't just serve these up to you in the output, because the raw value of some channels may be something that is unwieldy/undesirable - for example, the display value could have been in gigabytes (an easy value to work with) but the raw value could be bytes!
  • As such, Get-SensorHistory needs to extract the numeric value to use from your channel from the display value of the channel

Now that we understand how Get-SensorHistory works, we can now analyze the following XML

<item>
    <datetime>28.05.2021 08:48:46</datetime>
    <datetime_raw>44344.2838735764</datetime_raw>
    <value channel="MMA-Option:CRW" channelid="2">8&apos;544 #</value>
    <value_raw channel="MMA-Option:CRW" channelid="2">8544.0000</value_raw>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
</item>

In this XML, we have a channel MMA-Option:CRW whose raw value was 8544.0000. However, its display value was 8'544 - with an apostrophe, not a comma! I am not aware of any number system that uses an apostrophe as a decimal separator; my understanding is that all number cultures use either a period or a comma.

Are you able to install PrtgAPI on your PRTG Core Server (if it isn't already), run the following commands below on your PRTG Core Server the output?

Get-PrtgClient -Diagnostic

(get-culture).numberformat

Regards,
lordmilko

@schoenm1
Copy link
Author

Hi @lordmilko
I don't think I'm allowed to install PRTGAPI on Core Server... I will check it.
Interesting:
PRTG Server 1: 21.1.66.1664+ / return value is "8544" => Issue
PRTG Server 2: 20.4.64.1402+ / return value is "2592" => no issue

@lordmilko
Copy link
Owner

Hi @schoenm1,

No worries; in that case, simply running the following on the core server should suffice:

get-culture

(get-culture).numberformat

@schoenm1
Copy link
Author

Server 1 (Issue)

(get-culture).numberformat
CurrencyDecimalDigits    : 2
CurrencyDecimalSeparator : .
IsReadOnly               : False
CurrencyGroupSizes       : {3}
NumberGroupSizes         : {3}
PercentGroupSizes        : {3}
CurrencyGroupSeparator   : ' => is this the issue? The (') is the normal way for separating 1'000 or 1'000'000 in Switzerland.
CurrencySymbol           : CHF
NaNSymbol                : NaN
CurrencyNegativePattern  : 2
NumberNegativePattern    : 1
PercentPositivePattern   : 1
PercentNegativePattern   : 1
NegativeInfinitySymbol   : -∞
NegativeSign             : -
NumberDecimalDigits      : 2
NumberDecimalSeparator   : .
NumberGroupSeparator     : '
CurrencyPositivePattern  : 2
PositiveInfinitySymbol   : ∞
PositiveSign             : +
PercentDecimalDigits     : 2
PercentDecimalSeparator  : .
PercentGroupSeparator    : '
PercentSymbol            : %
PerMilleSymbol           : ‰
NativeDigits             : {0, 1, 2, 3...}
DigitSubstitution        : None

Server 2 (no Issue)

(get-culture).numberformat
CurrencyDecimalDigits    : 2
CurrencyDecimalSeparator : .
IsReadOnly               : False
CurrencyGroupSizes       : {3}
NumberGroupSizes         : {3}
PercentGroupSizes        : {3}
CurrencyGroupSeparator   : ,
CurrencySymbol           : $
NaNSymbol                : NaN
CurrencyNegativePattern  : 0
NumberNegativePattern    : 1
PercentPositivePattern   : 1
PercentNegativePattern   : 1
NegativeInfinitySymbol   : -∞
NegativeSign             : -
NumberDecimalDigits      : 2
NumberDecimalSeparator   : .
NumberGroupSeparator     : ,
CurrencyPositivePattern  : 0
PositiveInfinitySymbol   : ∞
PositiveSign             : +
PercentDecimalDigits     : 2
PercentDecimalSeparator  : .
PercentGroupSeparator    : ,
PercentSymbol            : %
PerMilleSymbol           : ‰
NativeDigits             : {0, 1, 2, 3...}
DigitSubstitution        : None

@lordmilko
Copy link
Owner

Hi @schoenm1,

Are you also able to include the output of get-culture from both servers?

@schoenm1
Copy link
Author

Server 1 (Issue)

PS C:\> Get-Culture
LCID             Name             DisplayName
----             ----             -----------
2055             de-CH            German (Switzerland)

Server 2 (no Issue)

PS C:\> Get-Culture
LCID             Name             DisplayName
----             ----             -----------
1033             en-US            English (United States)

@lordmilko
Copy link
Owner

Thanks @schoenm1,

I see that the issue is in fact that the NumberGroupSeparator in the de-CH culture is an apostrophe (as you say, this is evidently normal in switzerland). Windows on PRTG Server 2 is not configured to use the Switzerland culture, hence why it does not have the issue

Given this, I think I will need to audit all possible cultures that one could have and ensure PrtgAPI can handle their numbers properly. In the meantime, a potential workaround could be to potentially set server 1 to use the en-US culture as well (simply change the region in Control Panel and restart PRTG)

Regards,
lordmilko

@lordmilko lordmilko added bug Issues that have been confirmed to be bugs in PrtgAPI and will be fixed in a future version and removed question Questions raised by people who don't know how to program or read the wiki :P labels May 28, 2021
@schoenm1
Copy link
Author

Hi @lordmilko
Thanks for your help. I will try this. The only problem is that I have to announce a maintenance windows and can not test it asap.

lordmilko added a commit that referenced this issue May 29, 2021
…lues with theoretically any single character thousands/decimal group separator combination (#221)
@lordmilko
Copy link
Owner

Hi @schoenm1,

I have pushed a new build which should hopefully resolve this issue. Can you please try and run the latest build using the manual installation instructions and advise whether your Get-SensorHistory requests against PRTG Server 1 now work without issue?

Regards,
lordmilko

@lordmilko
Copy link
Owner

Hi @schoenm1,

Just following up on this; are you able to advise whether the latest build resolved the issue?

@schoenm1
Copy link
Author

schoenm1 commented Jun 2, 2021

Hi @lordmilko
Now the failing Sensor (region related) is working with latest 0.9.15 Version. Thanks a lot.
Do you have a plan when the next official PRTGApi release with this 'bug'fix will be published?

@schoenm1 schoenm1 closed this as completed Jun 2, 2021
@lordmilko
Copy link
Owner

Hi @schoenm1,

I hope to release PrtgAPI 0.9.16 as soon as #222 is confirmed resolved

@lordmilko
Copy link
Owner

Hi @schoenm1,

Please be advised PrtgAPI 0.9.16 has now been released. To update PrtgAPI, please run Update-Module PrtgAPI and reopen PowerShell

Regards,
lordmilko

@LumKitty
Copy link

LumKitty commented Sep 13, 2021

I have this issue in 0.9.16

> $History = Get-Sensor -Id $PRTGSensorID | Get-SensorHistory -EndDate $StartDate -StartDate $EndDate

Get-SensorHistory : Don't know how to convert double value '1.4444' (86.661).
At line:1 char:43
+ ... GSensorID | Get-SensorHistory -EndDate $StartDate -StartDate $EndDate ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-SensorHistory], NotImplementedException
    + FullyQualifiedErrorId : System.NotImplementedException,PrtgAPI.PowerShell.Cmdlets.GetSensorHistory

# These are from the server where I'm running the script, not the PRTG server itself
> Get-PrtgClient -Diagnostic

PSVersion      : 5.1.14393.4583
PSEdition      : Desktop
OS             : Microsoft Windows Server 2016 Standard
PrtgAPIVersion : 0.9.16
Culture        : en-GB
CLRVersion     : .NET Framework 4.8 (528049)
PrtgVersion    : 21.2.67.1562
PrtgLanguage   : Unknown

> Get-Culture

LCID             Name             DisplayName                                                                                                                                                                 
----             ----             -----------                                                                                                                                                                 
2057             en-GB            English (United Kingdom)                                                                                                                                                    

> (get-culture).numberformat

CurrencyDecimalDigits    : 2
CurrencyDecimalSeparator : .
IsReadOnly               : False
CurrencyGroupSizes       : {3}
NumberGroupSizes         : {3}
PercentGroupSizes        : {3}
CurrencyGroupSeparator   : ,
CurrencySymbol           : £
NaNSymbol                : NaN
CurrencyNegativePattern  : 1
NumberNegativePattern    : 1
PercentPositivePattern   : 1
PercentNegativePattern   : 1
NegativeInfinitySymbol   : -∞
NegativeSign             : -
NumberDecimalDigits      : 2
NumberDecimalSeparator   : .
NumberGroupSeparator     : ,
CurrencyPositivePattern  : 0
PositiveInfinitySymbol   : ∞
PositiveSign             : +
PercentDecimalDigits     : 2
PercentDecimalSeparator  : .
PercentGroupSeparator    : ,
PercentSymbol            : %
PerMilleSymbol           : ‰
NativeDigits             : {0, 1, 2, 3...}
DigitSubstitution        : None

Sample XML from this sensor:

<item>
    <datetime>9/12/2021 7:21:40 AM</datetime>
    <datetime_raw>44451.2650571181</datetime_raw>
    <value channel="02_DISKNAME - TimeLag" channelid="2">0.0000 Minutes</value>
    <value_raw channel="02_DISKNAME - TimeLag" channelid="2">0.0000</value_raw>
    <value channel="02_DISKNAME - Bytes to Send" channelid="3">0 MB</value>
    <value_raw channel="02_DISKNAME - Bytes to Send" channelid="3">0.0000</value_raw>
    <value channel="02_DISKNAME - Replication Buffer Free Space" channelid="4">100 %</value>
    <value_raw channel="02_DISKNAME - Replication Buffer Free Space" channelid="4">100.0000</value_raw>
    <value channel="04_DISKNAME - TimeLag" channelid="5">0.0003 Minutes</value>
    <value_raw channel="04_DISKNAME - TimeLag" channelid="5">0.0150</value_raw>
    <value channel="04_DISKNAME - Bytes to Send" channelid="6">0 MB</value>
    <value_raw channel="04_DISKNAME - Bytes to Send" channelid="6">0.0000</value_raw>
    <value channel="04_DISKNAME - Replication Buffer Free Space" channelid="7">100 %</value>
    <value_raw channel="04_DISKNAME - Replication Buffer Free Space" channelid="7">100.0000</value_raw>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
   </item>
  </histdata>

@lordmilko
Copy link
Owner

Hi @LumKitty,

Can you please try with the latest pre-release version and advise if this issue is still happening? Please see the manual installation instructions for more info on running this pre-release version

If it still does not work in the latest pre-release version, please provide the output of Get-PrtgClient -Diagnostic in the PowerShell instance you attempted to run that version

@LumKitty
Copy link

LumKitty commented Sep 14, 2021

Same issue using the version downloaded from that link.

However that version also reports itself as 0.9.16 so I could just be being a derp and running the wrong version. I can't find another version anywhere, apart from earlier releases

PSVersion      : 5.1.14393.4583
PSEdition      : Desktop
OS             : Microsoft Windows Server 2016 Standard
PrtgAPIVersion : 0.9.16
Culture        : en-GB
CLRVersion     : .NET Framework 4.8 (528049)
PrtgVersion    : 21.2.67.1562
PrtgLanguage   : Unknown

@lordmilko
Copy link
Owner

Hi @LumKitty,

If you're using the pre-release version it should look like this

PSVersion      : 5.1.14393.4583
PSEdition      : Desktop
OS             : Microsoft Windows Server 2016 Standard
PrtgAPIVersion : 0.9.17-preview.5
Culture        : en-US
CLRVersion     : .NET Framework 4.8 (528049)
PrtgVersion    : 21.2.67.1562
PrtgLanguage   : english.lng

If you

  1. Download the latest build
  2. Right click PrtgAPI.zip -> Properties
  3. On the General tab, under Security select Unblock
  4. Unzip the file
  5. Open the PrtgAPI.cmd file within
  6. Connect to your regular PRTG server
  7. Do Get-PrtgClient -Diagnostic

It should hopefully show the right version, in which case are you able to see if the issue still occurs there? There was an issue in #223 in June that I fixed in this pre-release version, so this may be that same issue.

@LumKitty
Copy link

Aha, I was being a derp, in my script I needed to import the .psd1 not the .psm1 to get 0.9.17-preview.5

Unfortunately, still the same issue


PSVersion      : 5.1.14393.4583
PSEdition      : Desktop
OS             : Microsoft Windows Server 2016 Standard
PrtgAPIVersion : 0.9.17-preview.5
Culture        : en-GB
CLRVersion     : .NET Framework 4.8 (528049)
PrtgVersion    : 21.2.67.1562
PrtgLanguage   : Unknown

@lordmilko
Copy link
Owner

Thanks @LumKitty,

It sounds like this is a new bug. Based on the exception message you're getting

Get-SensorHistory : Don't know how to convert double value '1.4444' (86.661).

I expect there should be an entry in the XML output that contains the numbers 1.4444 and 86.661. Are you able to provide the XML output containing these values? As I think you've already surmised, you can get this XML output by doing

Set-PrtgClient -LogLevel All

Get-Sensor -Id $PRTGSensorID | Get-SensorHistory -EndDate $StartDate -StartDate $EndDate -Verbose

@LumKitty
Copy link

LumKitty commented Sep 14, 2021

It's erroring in a different place today, may just be due to new data but here we are..

Get-SensorHistory : Don't know how to convert double value '1.3863' (83.177).
At C:\Scripts\VeeamReport.ps1:91 char:47
+ ... GSensorID | Get-SensorHistory -EndDate $StartDate -StartDate $EndDate ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-SensorHistory], NotImplementedException
    + FullyQualifiedErrorId : System.NotImplementedException,PrtgAPI.PowerShell.Cmdlets.GetSensorHistory
   <item>
    <datetime>9/14/2021 9:22:27 AM</datetime>
    <datetime_raw>44453.3489344560</datetime_raw>
    <value channel="02_DISKNAME - TimeLag" channelid="2">1.3863 Minutes</value>
    <value_raw channel="02_DISKNAME - TimeLag" channelid="2">83.1770</value_raw>
    <value channel="02_DISKNAME - Bytes to Send" channelid="3">303 MB</value>
    <value_raw channel="02_DISKNAME - Bytes to Send" channelid="3">317280256.0000</value_raw>
    <value channel="02_DISKNAME - Replication Buffer Free Space" channelid="4">100 %</value>
    <value_raw channel="02_DISKNAME - Replication Buffer Free Space" channelid="4">100.0000</value_raw>
    <value channel="04_DISKNAME - TimeLag" channelid="5">0.0003 Minutes</value>
    <value_raw channel="04_DISKNAME - TimeLag" channelid="5">0.0150</value_raw>
    <value channel="04_DISKNAME - Bytes to Send" channelid="6">0 MB</value>
    <value_raw channel="04_DISKNAME - Bytes to Send" channelid="6">0.0000</value_raw>
    <value channel="04_DISKNAME - Replication Buffer Free Space" channelid="7">100 %</value>
    <value_raw channel="04_DISKNAME - Replication Buffer Free Space" channelid="7">100.0000</value_raw>
    <coverage>100 %</coverage>
    <coverage_raw>0000010000</coverage_raw>
   </item>

@lordmilko
Copy link
Owner

Thanks @LumKitty,

I see what the issue is; in the meantime, depending on your use case you may be able to work around this by doing Get-SensorHistory -Raw to get the raw channel values (e.g. 83 seconds for channel TimeLag rather than the pretty value 1.3 Minutes)

@lordmilko
Copy link
Owner

Hi @LumKitty,

Are you able to advise what sort of sensor this is? Is this a built-in sensor in PRTG, or is this a custom channel you've written yourself? If it's the latter, are you able to provide the XML used to define the 02_DISKNAME - TimeLag channel?

Regards,
lordmilko

@LumKitty
Copy link

It's EXEXML, I'm producing it like this:

    Write-Output "
        <?xml version=`"1.0`"?>
        <prtg>
            <error>0</error>
            <text>$Message</text>"
    ForEach ($Replica in $Replicas) {
        Write-Output "
            <result>
                <channel>$($Replica.Caption) - TimeLag</channel>
                <value>$($TimeLag / 1000)</value>
                <unit>Seconds</unit>
                <mode>Absolute</mode>
                <limitmaxwarning>900</limitmaxwarning>
                <limitmaxerror>1800</limitmaxerror>
                <limitmode>1</limitmode>
                <float>1</float>
            </result>
            <result>
                <channel>$($Replica.Caption) - Bytes to Send</channel>
                <value>$($Performance.BytesToSend)</value>
                <unit>BytesDisk</unit>
                <mode>Absolute</mode>
                <volumesize>MegaByte</volumesize>
                <float>0</float>
            </result>
            <result>
                <channel>$($Replica.Caption) - Replication Buffer Free Space</channel>
                <value>$($Performance.ReplicationBufferPercentFreeSpace)</value>
                <unit>Percent</unit>
                <mode>Absolute</mode>
                <float>0</float>
                <limitminwarning>25</limitminwarning>
                <limitminerror>10</limitminerror>
                <limitmode>1</limitmode>
                <float>0</float>
            </result>"
    }
    Write-Output "    </prtg>"

@lordmilko
Copy link
Owner

Thanks @LumKitty,

I think I have the complete picture of what is going on here; are you able to check the settings of the 02_DISKNAME - TimeLag channel in PRTG and advise if this channel has a Scaling Division value of 60 applied to it?

I believe the reason the issue is occurring is that because the EXEXML sensor was configuring with an illegal <unit> of Seconds (it should be TimeSeconds) for the TimeLag channel, and when the channels were first created they displayed in PRTG with a unit of #, which is not what was desired. As such, I believe the settings of this channel were then modified to

  • Hardcode the unit to Minutes
  • Set the scaling multiplier to 60 so that the value displays in minutes instead of seconds

PrtgAPI knows how to convert the value of a channel to a TimeSpan for displaying in the sensor history output, however it doesn't know how to deal with custom scaling divisions, so there is definitely a bug there, however I would like to confirm if that is indeed what is happening here

Regards,
lordmilko

@LumKitty
Copy link

Yeah that's exactly right, and now I realise why PRTG wasn't handling the time well. I'll go and fix my sensor :)
Hopefully I can do that without screwing up the existing data.

@lordmilko
Copy link
Owner

Hi @LumKitty,

Please be advised this is now being tracked in #241; please subscribe to that issue for further updates as to when this issue is resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that have been confirmed to be bugs in PrtgAPI and will be fixed in a future version
Projects
None yet
Development

No branches or pull requests

3 participants