Currently, I was able to extract the current value by doing something like: https://website/api/getsensordetails.json?id=2143&username=something&passhash=something
Though this will only show it's last value. Is there any way to get the daily values, like for the previous month, or week?
Article Comments
Thanks Stephan, found this a few minutes ago. Is there an option to get the historic data like (7days ago or 1 month ago) instead of putting in start and end date?
Jan, 2019 - Permalink
Instead of the start and end date, you could use:
Get-SensorHistory -EndDate (Get-Date).AddDays(-31)
...to get the last month :)
PRTG Scheduler |
PRTGapi |
Feature Requests |
WMI Issues |
SNMP Issues
Kind regards,
Stephan Linke, Tech Support Team
Jan, 2019 - Permalink
Thanks for the reply Stephan. How should that go in an API call like this?
/api/historicdata.json?id=objectid&avg=0&sdate=2018-01-20-00-00-00&edate=2018-01-21-00-00-00&usecaption=1
Jan, 2019 - Permalink
That would be the following:
$start = [datetime]::ParseExact("2018-01-20-00-00-00", "yyyy-MM-dd-HH-mm-ss", $null) $end = [datetime]::ParseExact("2018-01-21-00-00-00", "yyyy-MM-dd-HH-mm-ss", $null) Get-SensorHistory -StartDate $start -EndDate $end
PRTG Scheduler |
PRTGapi |
Feature Requests |
WMI Issues |
SNMP Issues
Kind regards,
Stephan Linke, Tech Support Team
Jan, 2019 - Permalink
Your Vote:
Instead of the start and end date, you could use:
Get-SensorHistory -EndDate (Get-Date).AddDays(-31) ...to get the last month :)
Exampple above for prev month? how about for previous week for (monday-sunday?)
Dec, 2019 - Permalink
That kind of date calculation isn't easy with PowerShell. Check out the following to obtain the corresponding datetime objects for previous weekdays.
Dec, 2019 - Permalink
PRTG API's Historic Data function is your friend in this case :)
PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues
Kind regards,
Stephan Linke, Tech Support Team
Jan, 2019 - Permalink