I wanted to know how you configure plugin for monitoring postgres databases.
In this plugin I should enter
DB username
path to .env file
instance username
path to .pgpass file
I tried use these env i pgpass files but without success
Could you put your “working” postgres.cfg .env and pgpass files please to check how these should looks
And mayby I should configure something else to working properly?
in our case the agent plugin works out of the box as soon as it is deployed in the plugin dir of the agent on the Postgres host (thus it uses the default “postgres” user).
Did you have a look inside the plugin – esp. the function that parses the configuration file? Maybe that could help you get a clue why your config fails?
There is an example for Linux in the function’s docstring. Also, notice the different separator for Windows in the first if-statement of the function:
def parse_postgres_cfg(postgres_cfg):
"""
Parser for Postgres config. x-Plattform compatible.
Example for .cfg file:
DBUSER=postgres
INSTANCE=/home/postgres/db1.env:USER_NAME:/PATH/TO/.pgpass
INSTANCE=/home/postgres/db2.env:USER_NAME:/PATH/TO/.pgpass
"""
if IS_LINUX:
conf_sep = ":"
elif IS_WINDOWS:
conf_sep = "|"
else:
raise NotImplementedError("The OS type(%s) is not yet implemented." % platform.system())
dbuser = None
instances = []
for line in postgres_cfg:
if line.startswith("#") or "=" not in line:
continue
line = line.strip()
key, value = line.split("=")
if key == "DBUSER":
dbuser = value.rstrip()
if key == "INSTANCE":
env_file, pg_user, pg_passfile = value.split(conf_sep)
env_file = env_file.strip()
pg_database, pg_port = parse_env_file(env_file)
instances.append({
"name": env_file.split(os.sep)[-1].split(".")[0],
"pg_user": pg_user.strip(),
"pg_passfile": pg_passfile.strip(),
"pg_database": pg_database,
"pg_port": pg_port,
})
if dbuser is None:
raise ValueError("DBUSER must be specified in postgres.cfg")
return dbuser, instances
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.