Hi, i hope someone can help me... I'm working for now 2 weeks on a sensor, that shows me how old a backup is. The result from the PowerShell script is:
<prtg> <result> <channel>Backup Job 1</channel> <value>21</value> </result> <result> <channel>Backup Job 2</channel> <value>248</value> </result> <result> <channel>Backup Job 3</channel> <value>18</value> </result> </prtg>
The scipt worked verry well, but when i create a custom XML sensor the values are wrong. In this case:
Backup Job 1 = 84 Backup Job 2 = 384 Backup Job 3 = 194 The code is very simple: $BackupJob1 = "Backup Job 1" $LastBackup1 = (Get-ChildItem 'backups:\Backup Job 1').LastWriteTime | Sort-Object LastWriteTime | Select-Object -Last 1 $BackupAge1 = (Get-Date) - $LastBackupJonas | Select-Object -Property Days | Format-Wide | Out-String $BackupAge1 = $BackupAge1.Trim() $BackupAge1 = $BackupAge1.ToDecimal($null)
The integer that comes out of the Sript is right, but PRTG shows a different one... I don't know why and i can't see a scheme on it.
I hope some one can help me, I'm despairing.
Greetings from Germany
Article Comments
After a lot of Troubleshooting and logging i found the Problem in PowerShell itself. When i run the script in ISE the sort function works fine. When i run the script direktly, like PRTG does, the sort function don't include all objects. This is why the script gave out a wrong value. I think the sort function had a Problem with the pipelining…
I wrote a new script without integrating the sort funktion in the pipeline and now it works.
Thanks for the food for thought, Mr. Mikulik.
I hope i could help someone with this entry.
Greetings from Germany
Oct, 2019 - Permalink
Hi there,
I'll send you an email shortly about sending us logs from the sensor itself.
Kind regards,
Erhard
Sep, 2019 - Permalink