Starting from TKU September 2020 Database Schema node type and Database Table node type were updated to contain DB Server type. (DRDC1-14748)
e.g. SQL Database Schema type was changed to PostgreSQL Database Schema and SQL Database Table type was replaced with PostgreSQL Database Table.
Current pattern allows to discover and model all databases and tables for PostgreSQL Database Server or EnterpriseDB Postgres Advanced Server instances as Detail nodes.
There are several configuration options available for this product:
The pattern identifies databases and tables of PostgreSQL Database Server or EnterpriseDB Postgres Advanced Server running on Windows and UNIX platforms.
|PostgreDatabasesAndTables||SoftwareInstance created, confirmed||type||in||"PostgreSQL Database Server", "EnterpriseDB Postgres Advanced Server"|
The ProstgreSQL database, schema and table information is stored within the Discovery Model as DatabaseDetail Nodes.
Current pattern module contains Configuration section which allows to disable discovery for specified databases and schemas.
By default the pattern skips:
The pattern tries to run command which generates the dump of all PostgreSQL databases structures (without data) by means of command:
'"<base_si.bin_dir>/pg_dumpall" -U <adminuser> -s -x'
or if <base_si.bin_dir> doew not exist, then default value for UNIX host is used:
'/usr/bin/pg_dumpall -U <adminuser> -s -x'
where <base_si.bin_dir> is 'bin_dir' attribute of trigger "PostgreSQL Database Server" or "EnterpriseDB Postgres Advanced Server" SI.
NOTE: If <adminuser> value is not specified in pattern Configuration section then default 'postgres' user is used. <adminuser> should have 'trust' access to all databases specified in pg_hba.conf file. Here is an example of "/var/lib/pgsql/data/pg_hba.conf" file' entry:
Command output is split by string "\\connect", where each such chunk represents dump for one specific database ("PostgreSQL Database") which is used for obtaining database name (db_name):
then, each database dump is split by string "SET search_path" in order to get chunks for each available "PostgreSQL Database Schema" which is used for obtaining schema name (schema_name)
if no schema_name was ontained then default "public" schema name is used.
The tables list("PostgreSQL Database Table") are extracted from each schema chunk by regex:
regex '(?i)CREATE TABLE\s+(\S+)\s+\('
Table and Schema modeling can be disabled (leaving only databases modelling) by switching to 'false' correspondent Configuration option in the pattern.
If the first active method failed ( pg_dumpall command does not have admin access) pattern tries to run the following command:
From the command output pattern extracts list of DB names by means of regex:
Databases list("PostgreSQL Database") is obtained using sql query:
then, for each obtained database the pattern runs the following sql query:
The pattern also allows to obtain database list("PostgreSQL Database") from the file "<base_si.data_dir>/global/pg_database" by means of regex:
where <base_si.data_dir> is 'data_dir' attribute of "PostgreSQL Database Server" SI.
PostgreDatabasesAndTables pattern triggers on the each created or confirmed PostgreSQL Database Server Software Instance.
Detail key consists of the key of the parent PostgreSQL Database Server instance and original database or table name, returned by active command.
Subject Matter Expert input will be welcome on any other potential approaches not discussed to improve the depth of PostgreSQL Database Server - Database Detail Pattern.
The pattern has been tested against live installations of the PostgreSQL Database Server product on Windows and Linux CentOS platforms.
There are no known open issues with this pattern.