Nagios XI includes a PostgreSQL Query wizard that enables you to easily run a custom SQL query and quickly configure warning/critical thresholds based on the number of matching results. You can also refer to this documentation for full details: Here is a direct link to the PDF as well Monitoring PostgreSQL Queries