Is it possible to setup a postgreSQL sensor with a query that checks a "last updated" timestamp column to make sure the date/time is < 24 hours old? If the last update value is > 24 hours older than the current system date/time it sends a warning or down?


Article Comments

Hi Nightowl,

How does the output of the column look like? Is it a date format or an integer like seconds since last update?


Kind regards,
Felix Saure, Tech Support Team


May, 2019 - Permalink

It is a date format: 2019-05-20 01:11:47-07


May, 2019 - Permalink

Hello Nightowl,

Then it would be required to calculate the difference between the current system time and the time returned in that table. The result needs to be a single integer which is then return to PRTG in the script. You can use the DATEDIFF() function for that.

DATEDIFF ( datepart , startdate , enddate ) 

This is documented here: https://docs.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql?view=sql-server-2017

In PRTG itself you can then click on the gauge symbol of the channel and configure the limits as desired.


Kind regards,
Felix Saure, Tech Support Team


May, 2019 - Permalink

I don't think postgres has a datediff function, does it?

It has date_part, so perhaps I can use that...as long as it returns an integer, right?

Then, do I interpret the result in the alert notifications?


May, 2019 - Permalink

Hi Nightowl,

I haven't worked with it so far, but according to this article, datediff should work.

Anyways, you're right, an integer / float needs to be returned. The thresholds are set in the sensor settings to define if the sensor should go into an error after a particular time. Te status will then also be visible in the notifications you send.


Kind regards,
Felix Saure, Tech Support Team


May, 2019 - Permalink