ikzelf / zbxdb

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

Inaccurate documentation of config file / zbxdb.py returns error #1

Closed sliwa95 closed 6 years ago

sliwa95 commented 6 years ago

Can't use Oracle Wallet (have to run ZbxDB on different machine than both Zabbix server and Oracle instance), so have to live with usr/pwd in config file. Documentation doesn't show how to configure it currently, so I've tried setting _passwordenc with default value, empty or even commenting it, same error on run.

Another thing. Documentation shows different config file layout than files in repo (documentation says username: zbxdbmon while in files in repo it is username = zbxdbmon. Which one is correct?


Trying to run configured ZabbixDB with command: zbxdb.py -c etc/zbxdb.orabss.cfg

Traceback (most recent call last):
  File "/home/msiwania/zbxdb/bin/zbxdb.py", line 146, in <module>
    config = get_config(ARGS.configfile)
  File "/home/msiwania/zbxdb/bin/zbxdb.py", line 126, in get_config
    enc = encrypted(config['password'])
  File "/home/msiwania/zbxdb/bin/zbxdb.py", line 59, in encrypted
    return base64.b64encode(bytes(plain, 'utf-8'))
TypeError: str() takes at most 1 argument (2 given)

zbxdb.orabss.cfg looks like:

[zbxdb]
db_url = //IP-ADDRESS/ORAPROD1
username = zbxdbmon
password = glaAC3a7b
db_type = oracle
db_driver = cx_Oracle
instance_type = rdbms
role = normal
out_dir = $HOME/zbxora_out
hostname = OracleDB1
checks_dir = etc/zbxdb_checks
site_checks = sap,ebs
password_enc = whatever
ikzelf commented 6 years ago

Hi, I fixed the docu regarding the "keyword = value" issue, as it should be with "=". Thanks for catching that. The idea is that you start with password = yourplaintextpassword and keep password_enc empty. zbxdb.py should see that as a reason to encrypt the password and write the config file with password empty and password_enc filled with the 'encrypted' version.

Regarding oracle wallet .... you can create the wallet on a database server since the tools are only in the rdbms installation and not in the clients installation and copy that to your client.

$>cat etc/z.cfg [zbxdb] db_url = //IP-ADDRESS/ORAPROD1 username = zbxdbmon password = verysekret db_type = oracle db_driver = cx_Oracle instance_type = rdbms role = normal out_dir = $HOME/zbxora_out hostname = OracleDB1 checks_dir = etc/zbxdb_checks site_checks = sap,ebs password_enc = client ronr@ronrmb03:~/Documents/git/zbxdb $>bin/zbxdb.py -c etc/z.cfg 2018-09-04 13:33:27 start python-3.6.4 zbxdb-0.69 pid=65208 Connecting for hostname OracleDB1... 2018-09-04 13:33:27 first encrypted the plaintext password and removed from config 2018-09-04 13:33:27.115552 zbxdb found db_type=oracle, driver cx_Oracle; checking for driver <module 'cx_Oracle' from '/Users/ronr/.pyenv/versions/3.6.4/lib/python3.6/site-packages/cx_Oracle.cpython-36m-darwin.so'> 2018-09-04 13:33:27.126744 zbxdb driver cx_Oracle loaded 2018-09-04 13:33:27.131736 zbxdb driver drivererrors for cx_Oracle loaded 2018-09-04 13:33:27.134124 zbxdb dbconnections for oracle loaded <module 'dbconnections.oracle' from '/Users/ronr/Documents/git/zbxdb/bin/dbconnections/oracle.py'> <module 'drivererrors.cx_Oracle' from '/Users/ronr/Documents/git/zbxdb/bin/drivererrors/cx_Oracle.py'> 2018-09-04 13:33:27.134213 site_checks: sap,ebs 2018-09-04 13:33:27.134225 out_file:/Users/ronr/zbxora_out/z.zbx 2018-09-04 13:33:27.517331: (1.1)connection error: [12154] ORA-12154: TNS:could not resolve the connect identifier specified for zbxdbmon@//IP-ADDRESS/ORAPROD1 ^CTraceback (most recent call last): File "bin/zbxdb.py", line 246, in conn = dbc.connect(dbdr, config) File "/Users/ronr/Documents/git/zbxdb/bin/dbconnections/oracle.py", line 55, in connect return db.connect(connect_string(c), mode=c['omode']) cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "bin/zbxdb.py", line 599, in time.sleep(SLEEPER) KeyboardInterrupt

$>cat etc/z.cfg [zbxdb] db_url = //IP-ADDRESS/ORAPROD1 username = zbxdbmon password = db_type = oracle db_driver = cx_Oracle instance_type = rdbms role = normal out_dir = $HOME/zbxora_out hostname = OracleDB1 checks_dir = etc/zbxdb_checks site_checks = sap,ebs password_enc = Z2xxYZyXzYTdi

marvinmbh commented 6 years ago

Hello,

we are getting the same error. My zbxdb.odb.cfg file looks like this (changed db_url, password and hostname):

[zbxdb] db_url = //ip:1521/db username = zabmbh password = mypassword db_type = oracle db_driver = cx_Oracle instance_type = rdbms role = normal out_dir = $HOME/zbxora_out hostname = server checks_dir = etc/zbxdb_checks site_checks = sap,ebs password_enc =

When trying to run the script with "./bin/zbxdb.py -c ./etc/zbxdb.odb.cfg" this error occurs: Traceback (most recent call last): File "./bin/zbxdb.py", line 146, in config = get_config(ARGS.configfile) File "./bin/zbxdb.py", line 126, in get_config enc = encrypted(config['password']) File "./bin/zbxdb.py", line 59, in encrypted return base64.b64encode(bytes(plain, 'utf-8')) TypeError: str() takes at most 1 argument (2 given)

ikzelf commented 6 years ago

Which version of Python and which version of zbxdb.py are you using? They are reported on the first 3 lines on stdout of zbxdb.py

sliwa95 commented 6 years ago

Yeah, it was (so obvious now) Python version in my case. Have both 2.7 and 3.5.2, and my Ubuntu 16.04 defaulted to 2.7. On virtualenv it started working. Of course it did error on me after that, because I've forgot to create _zbxoraout directory ;)

Thanks for fast response with documentation and pointing to Python version.

I'll reedit issue, as it should point now as documentation inconsistency was real issue.

ikzelf commented 6 years ago

thanks for helping make zbxdb a better tool.