-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Report for the last 2 months using the PRTGapi #338
Comments
Hi @MPrica12, When you look on the logs tab of the sensor in PRTG, how many instances of the sensor being in status "Down" does it show between April 1st and May 31st? I would also note when you want to analyze sensor outages, the best way to do this is to generate a historical report, not look at the object event logs. You can obtain the same information you get by doing a historical report in the PRTG UI using the |
Hello @lordmilko, Thanks a lot for your response, I am working on making it working by using Get-SensorHistory, but I seem to be facing issues with the DateTire format of Powershell, I keep getting this error when running the below: $history = Get-Sensor -Id 74710 | Get-SensorHistory -Report -StartDate $StartDate -EndDate $EndDate | where Status -eq Down Get-SensorHistory: String '4/13/2023 10:06:17 AM'(example of time) was not recognized as a valid DateTime. I tried using ParseExact before running the command but I still get the same error: $EndDate1 = [DateTime]::ParseExact('01/04/2023 00:00:00', 'dd/MM/yyyy HH:mm:ss', $null) $history = Get-Sensor -Id 74710 | Get-SensorHistory -Report -StartDate $StartDate1 -EndDate $EndDate1 | where Status -eq Down Get-SensorHistory: String '4/13/2023 10:06:17 AM' was not recognized as a valid DateTime. |
Hi @MPrica12, Can you reproduce the exception with the datetime and then provide the output of |
Hi @lordmilko, Here is the output: PS C:\Scripts\Scripts Powershell> $error[0].Exception.StackTrace |
I just tried running it without any kind of startdate or enddate parameters and I get the same error: Get-SensorHistory: String '6/20/2023 2:01:11 PM' was not recognized as a valid DateTime. Here is the StackTrace: at System.DateTime.Parse(String s) |
This is a bug in PrtgAPI which is occurring because the datetime format of your system is MM/dd/yyyy. You can temporarily work around this by changing your date format in Windows to be dd/MM/yyyy. I will investigate what may be required to resolve this |
Hello @lordmilko I just did a few changes to the DateTime, now I get a different error: Get-SensorHistory: Failed to find the table 'table_statereporttable' in the specified HTML response. What do you think I should do about this? |
Can you please provide the output of In addition, if you execute C:\> get-sensor -id 2056|Get-SensorHistory -Report -verbose
http://prtg.example.com/historicdata_html.htm?edate... If you copy and paste this entire URL in your web browser it should bring up the report, with the Sensor Status History section down the bottom. If you're using Chrome, and then do Ctrl+Shift+J, you can use the Selector button to select the Sensor Status History header If you then look at the adjacent HTML inside the table-wrapper div and form, you should see a table The expected name of this table is |
Here is the output: PSVersion : 7.3.4 I will look into the table_statereporttable and will provide it soon, thank you! |
What's going on?
Hello,
I'm trying to create an export of all of the instances each sensors went down from an .xlsx file in the last 2 months
I'm not sure what the issue is but when I try to make an export from PRTG using the API and following the documentation in the Get-ObjectLog section the data being pulled in the export is only from the last 3 days, as those are the only instances when the sensors seems to have went down, which is impossible as we are sure some of those sensors went down in more times in the last 2 months. Am I configuring something wrong in my script?
$EndDate = Get-Date -Day 1 -Month 4 -Year 2023
$StartDate = Get-Date -Day 31 -Month 5 -Year 2023
$Xls = Import-Excel "C:\Monitoring_documents\Files_work\test.xlsx"
$export = foreach($line in $Xls.Id){
Write-Host "Processing sensor " $line
$Logs = Get-Sensor -id $line | Get-ObjectLog -StartDate $StartDate -EndDate $EndDate -Status Down
$Logs | Select-Object DateTime, Id, Name, Status, Message
Write-Host "Found sensor with down status in the period with ID " $Logs.Id
start-sleep 2
}
$export | Export-Csv C:\Monitoring_documents\Files_work\Sensors_down_updated.csv
Due Dilligance
The text was updated successfully, but these errors were encountered: