Hello,

I want to build an application that I can use in the morning to scan all the errors that have occurred during that night. Is there an API call that I can use which will give me the data shown in https://www.paessler.com/manuals/prtg/logs?


Article Comments

You can do this fairly easily with PrtgAPI, using either C# or PowerShell

The following shows the basic usage using PowerShell

C:\> Get-ObjectLog -Status Down

DateTime               Id     Name                       Device             Status         Message
--------               --     ----                       ------             ------         -------
20/03/2019 7:50:16 PM  2286   CPU Load                   exch-1             Down           92 % (Total) is above the...
20/03/2019 7:50:16 PM  2286   CPU Load                   exch-1             Down           92 % (Total) is above the...
20/03/2019 7:49:51 PM  2286   CPU Load                   exch-1             Down           93 % (Total) is above the...
20/03/2019 7:47:00 PM  2286   CPU Load                   exch-1             Down           93 % (Total) is above the...
20/03/2019 7:46:50 PM  2286   CPU Load                   exch-1             Down           97 % (Total) is above the...
20/03/2019 7:46:16 PM  2286   CPU Load                   exch-1             Down           93 % (Total) is above the...
20/03/2019 6:13:54 PM  2036   Ping                       8.8.8.8            Down           Destination network unrea...
20/03/2019 6:13:33 PM  2036   Ping                       8.8.8.8            Down           Destination network unrea...
20/03/2019 6:13:24 PM  2036   Ping                       8.8.8.8            Down           Destination network unrea...
20/03/2019 5:50:16 PM  2286   CPU Load                   exch-1             Down           93 % (Total) is above the...
20/03/2019 5:50:16 PM  2286   CPU Load                   exch-1             Down           93 % (Total) is above the...
20/03/2019 5:49:44 PM  2286   CPU Load                   exch-1             Down           92 % (Total) is above the...
20/03/2019 5:23:00 PM  2286   CPU Load                   exch-1             Down           100 % (Total) is above th...
20/03/2019 5:22:44 PM  2286   CPU Load                   exch-1             Down           94 % (Total) is above the...
20/03/2019 5:22:16 PM  2286   CPU Load                   exch-1             Down           100 % (Total) is above th...
20/03/2019 5:11:00 PM  2286   CPU Load                   exch-1             Down           92 % (Total) is above the...
...

You can specify a start and end range for your query, then group by ID to get a list of unique events

# Get all alerts that occurred in the last 24 hours
C:\> Get-ObjectLog -status Down -EndDate (get-date).adddays(-1) | group Id

Count Name                      Group
----- ----                      -----
   22 2286                      {20/03/2019 7:50:16 PM: CPU Load, 20/03/2019 7:50:16 PM: CPU Load, 20/03/2019 7:49:5...
   15 2036                      {20/03/2019 6:13:54 PM: Ping, 20/03/2019 6:13:33 PM: Ping, 20/03/2019 6:13:24 PM: Pi...
    1 2928                      {20/03/2019 11:09:31 AM: Service: PRTG Probe Service}
    3 2203                      {20/03/2019 3:27:00 AM: Memory Device 1 VDIMM, 20/03/2019 3:26:37 AM: Memory Device ...
    3 2204                      {20/03/2019 3:27:00 AM: Memory Device 64 P1-DIMMA1 Temp, 20/03/2019 3:26:35 AM: Memo...
    3 2205                      {20/03/2019 3:27:00 AM: Memory Device 65 P1-DIMMA2 Temp, 20/03/2019 3:26:33 AM: Memo...
    3 2206                      {20/03/2019 3:27:00 AM: Memory Device 68 P1-DIMMB1 Temp, 20/03/2019 3:26:31 AM: Memo...
    3 2207                      {20/03/2019 3:27:00 AM: Memory Device 69 P1-DIMMB2 Temp, 20/03/2019 3:26:30 AM: Memo...
...

Based on your requirements, this could simply be a one liner (with the end date simply being 5pm yesterday, etc) or you could wrap this up in a slightly more advanced application, potentially sending you an automated report, etc

Regards

lordmilko


Mar, 2019 - Permalink