# Discovery

This plugin can be integrated with Pandora FMS Discovery.

To do so, you must load the ".disco" package that you can download from the Pandora FMS library:

[https://pandorafms.com/library/](https://pandorafms.com/library/)

[![disco.png](https://pandorafms.com/guides/public/uploads/images/gallery/2026-05/scaled-1680-/MJedisco.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2026-05/MJedisco.png)

Once loaded, PostgreSQL environments can be monitored by creating Discovery tasks from the *Management &gt; Discovery &gt; Applications* section.

The following minimum data will be requested for each task:

- **PostgreSQL target strings**: List of PostgreSQL targets to be monitored by the task. It will be a comma-separated or line-separated list. Each PostgreSQL target can be defined using the format `IP:PORT` or `IP`, also allowing explicit selection or exclusion of databases (see *List of target databases*).
- **PostgreSQL Credentials**: Custom connection credentials used to access the PostgreSQL targets. A credential previously created in *Management &gt; Configuration &gt; Credential store* must be selected.

[![step2.png](https://pandorafms.com/guides/public/uploads/images/gallery/2026-05/scaled-1680-/gBUstep2.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2026-05/gBUstep2.png)

You can also adjust the task configuration to customize the desired monitoring:

- **Max threads:** To optimize execution time, multiple threads can be configured to monitor the task agents. Keep in mind that setting multiple threads may increase CPU usage.
- **Target agent:** List of target agents for the PostgreSQL targets to monitor. If an agent name is not specified for a target, its IP or FQDN will be used as the agent name.
- **Custom module prefix:** Text included as a prefix for all generated module names.
- **Scan databases:** If enabled, the plugin will discover the databases available on each PostgreSQL target.
- **Create agent per database:** If enabled, a separate agent will be created for each discovered database.
- **Custom database agent prefix:** Text included as a prefix for generated database agent names.
- **Enable entities file re-scan interval:** If enabled, the plugin will use a persistent discovered entities file to validate previously detected databases, even if they are no longer present in the current scan. This way, if a database disappears from the scan, its `connection` module can transition to a critical state instead of being silently dropped.
- **Re-scan entities file interval:** Interval used to revalidate the discovered entities file.
- **Check engine uptime:** If enabled, engine uptime monitoring will be performed.
- **Retrieve query statistics:** If enabled, instance-level query statistics will be monitored:
    - `queries`: Number of active queries within the configured interval.
    - `insert`: Number of active INSERT queries.
    - `delete`: Number of active DELETE queries.
    - `update`: Number of active UPDATE queries.
- **Analyze connections:** If enabled, instance connection usage will be monitored:
    - `session usage`: Percentage of connection usage compared to the configured maximum.
- **Calculate fragmentation ratio:** If enabled, fragmentation ratio statistics will be monitored:
    - `fragmentation ratio`: Estimated average fragmentation ratio.
- **Retrieve cache statistics:** If enabled, instance cache statistics will be monitored:
    - `allocated buffer cache`: Total allocated shared buffers.
    - `backend used buffer cache`: Buffers used by backend processes.
    - `checkpoints buffer cache`: Buffers written by checkpoints.
    - `cleaned buffer cache`: Buffers cleaned by the background writer.
- **Storage statistics:** If enabled, storage metrics for discovered databases will be monitored:
    - `database size`: Total database size.
    - `tables size`: Total space used by tables.
    - `indexes size`: Total space used by indexes.
    - `temp bytes`: Temporary data written to disk.
    - `temp files`: Number of temporary files created.
- **Query performance:** If enabled, query performance statistics will be monitored:
    - `long queries`: Number of active queries running longer than the configured interval.
    - `oldest query age`: Execution time of the oldest active query.
    - `sequential scans`: Number of sequential scans.
    - `index scans`: Number of index-based scans.
    - `cache hit ratio`: Database cache hit ratio.
- **Connections statistics:** If enabled, per-database connection statistics will be monitored:
    - `active connections`: Number of active connections.
    - `idle connections`: Number of idle connections.
    - `total connections`: Total number of open connections.
- **Transaction statistics:** If enabled, transaction activity will be monitored:
    - `transactions`: Total executed transactions.
    - `commits`: Committed transactions.
    - `rollbacks`: Rolled back transactions.
    - `rollback ratio`: Rolled back transactions ratio.
    - `deadlocks`: Detected deadlocks.
    - `conflicts`: Detected database conflicts.
- **Table statistics:** If enabled, structural table statistics will be monitored:
    - `table count`: Total number of user tables.
    - `index count`: Total number of user indexes.
    - `live tuples`: Estimated active rows.
    - `dead tuples`: Estimated obsolete rows pending cleanup.
    - `fragmentation ratio`: Estimated table fragmentation ratio.
- **Advanced performance:** If enabled, advanced performance metrics will be monitored:
    - `blocks read`: Blocks read from disk.
    - `blocks hit`: Blocks retrieved from cache.
- **Execute custom queries:** If enabled, custom queries can be executed against the PostgreSQL instance and discovered databases.
- **Custom queries:** Configuration block used to define custom queries to be executed. It supports the `target_scope` field (`instances`, `databases` or `all`) and the reserved word `$__self_dbname` to dynamically build the module name and the query depending on the database in which it is executed.

[![step3.png](https://pandorafms.com/guides/public/uploads/images/gallery/2026-05/scaled-1680-/wnAstep3.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2026-05/wnAstep3.png)

Discovery behavior:

- A main agent will always be created for each PostgreSQL target.
- If **Scan databases** is enabled, the databases of the target will be discovered.
- If **Create agent per database** is enabled, a separate agent will be created for each discovered database. Otherwise, the database modules will be created on the main agent using the database name as prefix.
- The **connection** module will always be created for each discovered database, even if no other tokens are enabled.
- The **POSTGRESQL connection** module will always be created on the main (instance) agent to reflect the global availability of the instance.
- When **Enable entities file re-scan interval** is enabled, previously detected databases are persisted in the entities file, so that if they no longer appear in the current scan, the plugin will keep generating their `connection` module (which can transition to a critical state) instead of removing them silently.

Successfully completed tasks will provide an execution summary with the following information:

- **Total agents**: Total number of agents generated by the task.
- **Targets up**: Total number of targets successfully connected.
- **Targets down**: Total number of targets that could not be reached.