ikzelf / zbxdb

Zabbix database monitoring, the easy and extendable way
GNU General Public License v3.0
94 stars 45 forks source link

I don`t connect to Postgresql 9 #44

Closed absz1980 closed 4 years ago

absz1980 commented 4 years ago

Hello, Ronald

I didn`t connect to Postgresql 9

[zbxdb@msk01-monapp02 log]$ pip install psycopg2 Requirement already satisfied: psycopg2 in /home/zbxdb/.pyenv/versions/3.6.5/lib/python3.6/site-packages (2.8.5) [zbxdb@msk01-monapp02 log]$

[zbxdb@msk01-monapp02 log]$ cat zbxdb.msk01-lfebdu05.cfg.log 2020-06-23 16:59:12,559main30_start python-3.6.5 zbxdb-2.07 pid=125661 Connecting ...

2020-06-23 16:59:12,560main30_first encrypted the plaintext password and removed from config

2020-06-23 16:59:12,560main30_zbxdb found db_type=postgres, driver psycopg2; checking for driver

2020-06-23 16:59:12,900main50_problem Traceback (most recent call last): File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 403, in main connect_info = db_connections.connection_info(_conn) File "/home/zbxdb/zbxdb/bin/dbconnections/postgres.py", line 36, in connection_info conn_info['iname'] = _data[0] TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 829, in main() File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 786, in main err_code, err_msg = driver_errors.db_errorcode(db_driver, dberr) File "/home/zbxdb/zbxdb/bin/drivererrors/psycopg2.py", line 8, in db_errorcode LOGGER.debug("db_errorcode %s %s\n", excep, excep.pgcode) AttributeError: 'TypeError' object has no attribute 'pgcode' 2020-06-23 17:00:12,611main30_start python-3.6.5 zbxdb-2.07 pid=126251 Connecting ...

2020-06-23 17:00:12,612main30_zbxdb found db_type=postgres, driver psycopg2; checking for driver

2020-06-23 17:00:12,670main50_problem Traceback (most recent call last): File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 403, in main connect_info = db_connections.connection_info(_conn) File "/home/zbxdb/zbxdb/bin/dbconnections/postgres.py", line 36, in connection_info conn_info['iname'] = _data[0] TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 829, in main() File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 786, in main err_code, err_msg = driver_errors.db_errorcode(db_driver, dberr) File "/home/zbxdb/zbxdb/bin/drivererrors/psycopg2.py", line 8, in db_errorcode LOGGER.debug("db_errorcode %s %s\n", excep, excep.pgcode) AttributeError: 'TypeError' object has no attribute 'pgcode' 2020-06-23 17:01:12,728main30_start python-3.6.5 zbxdb-2.07 pid=126848 Connecting ...

2020-06-23 17:01:12,728main30_zbxdb found db_type=postgres, driver psycopg2; checking for driver

2020-06-23 17:01:12,784main50_problem Traceback (most recent call last): File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 403, in main connect_info = db_connections.connection_info(_conn) File "/home/zbxdb/zbxdb/bin/dbconnections/postgres.py", line 36, in connection_info conn_info['iname'] = _data[0] TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 829, in main() File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 786, in main err_code, err_msg = driver_errors.db_errorcode(db_driver, dberr) File "/home/zbxdb/zbxdb/bin/drivererrors/psycopg2.py", line 8, in db_errorcode LOGGER.debug("db_errorcode %s %s\n", excep, excep.pgcode) AttributeError: 'TypeError' object has no attribute 'pgcode' [zbxdb@msk01-monapp02 log]$

absz1980 commented 4 years ago

[zbxdb@msk01-monapp02 example]$ cat zbxdb.msk01-lfebdu05.cfg [zbxdb] db_url = msk01-lfebdu05:5432/postgres username = zabbix password = db_type = postgres instance_type = rdbms db_driver = psycopg2 role = normal out_dir = $HOME/zbxdb_out hostname = msk01-lfebdu05 checks_dir = etc/zbxdb_checks site_checks = NONE password_enc = sql_timeout = 3

ikzelf commented 4 years ago

The problem seems to be that this query: select inet_server_addr()||':'||p.setting||':'|| d.setting from pg_settings p, pg_settings d where p.name = 'port' and d.name = 'data_directory';

does not return results. It does in my test db. Does your Zabbix user have the correct privileges? https://github.com/ikzelf/zbxdb#postgresql

I would prefer lesser privileges than superuser but postgres has a bit less on security than Oracle (and also, I know Oracle a bit better)

ikzelf commented 4 years ago

Did you get this up and running?

absz1980 commented 4 years ago

Yes. Thank you. The Issue is resolved.