-
Problem report
-
Resolution: Cannot Reproduce
-
Minor
-
None
-
None
-
None
-
CentOS 7, RHEL 7
Steps to reproduce:
- Import template https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql_agent2
- Create user in PostgreSQL, check the connection
- Create host in Zabbix - link with Template DB PostgreSQL Agent 2
Result:
All non-dependent items are unsupported
Error in zabbix_agent2.log - see the screenshot
Zabbix_get shows the same error for any item
zabbix_get -s 127.0.0.1 -p 10056 -k pgsql.bgwriter[tcp://127.0.0.1:5432,zbx_monitor,zabbix123] ZBX_NOTSUPPORTED: Cannoe Etabilish Connection To Postgres Server: Failed To Connect To `Host=127.0.0.1 User=Zbx_monitor Database=`: Server Error (Fatal: Database "Zbx_monitor" is not exists (SQLSTATE 3D000)).
Expected:
Correct data
Step for fix
Define database name in item key as the last parameter
Quiestion is - why this is not defined by default?
Defining Plugins.Postgres.Database=<dbname>
in zabbix_agent2.conf is not helping.
Alternative
Set parameters for session in zabbix_agent2.conf
Plugins.Postgres.Sessions.Postgres1.Host=<host> Plugins.Postgres.Sessions.Postgres1.Port=<port> Plugins.Postgres.Sessions.Postgres1.User=<UsernameForPostgres1> Plugins.Postgres.Sessions.Postgres1.Password=<PasswordForPostgres1> Plugins.Postgres.Sessions.Postgres1.Database=<DatabaseForPostgres1>
Next
Problem with item values in LLD
LLD pgsql.db.discovery["\\\\\\\\{$PG.URI}"]
Item prototype (by plugin description in https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/plugins/postgres)
pgsql.db.age[uri,username,password,dbName] — age of the oldest xid for each database. Used in databases discovery. Params: dbName — Database name. Mandatory.
Used SQL query
SELECT age(datfrozenxid)
FROM pg_catalog.pg_database
WHERE datistemplate = false
AND datname = <dbName>
All values for each database return the same value, but databasese were created in the different time
Why this item called as "Database age"?
Item prototype
pgsql.db.size[uri,username,password,dbName] — database size in bytes. Used in databases discovery. Params: dbName — Database name. Mandatory.
when plugin Session parameters are defined in zabbix_agent2.conf
return the same values for each database
But databases have a different size
Next
Mistake in SQL query in plugin description:
pgsql.db.discovery[uri,username,password,dbName] — Databases discovery. Params: dbName — Database name. Optional.
Returns: Result of the
SELECT age(datfrozenxid)
FROM pg_catalog.pg_database
WHERE datistemplate = false
AND datname = <dbName>
query have selecting result from pg_database table without defining any alias - there is a mistake with selecting column d.datname
Please, fix it