This alert will query the pg_database table and use the datallowconn value. If the value is 1, the database is not currently accepting connections and the alert query will return 1, otherwise the query returns 0.
To create the alert, create a Custom SQL Multiple Value alert and make it look similar to this example: