Giter VIP home page Giter VIP logo

zbxdb's Introduction

zbxdb

Zabbix Database monitoring plugin started as a copy from zbxora-1.98

Rate in zabbix share

Written in python, tested with python 3.6 Ready for python 3.9.2 since python 3.6 hits EOL in 2021-12 Using drivers available for python purpose is monitoring any database in an efficient way. Using zabbix_sender to upload data from crontab By popular demand: password fields are encrypted to password_enc fields during startup when a password value is detected. Not a simple hash but with strong key, complete with key rotation, if a key has been generated using "bin/zbxdb.py -c one_of_your.cfg -g". This will generate a key and place in in the keys directory for use of all your cfg's that are in the same directory.

When zbxdb detects changes in it's components (zbxdb.py itself, db connection and exception modules, configfile and in the keysdir) zbxdb.py auto restarts to activate the changes. If the used checks files are changed, they are automatically reloaded. Normally this happens within 1 minute. When zbxdb.py detects the removal of it's configfile, zbxdb.py stops running and because zbxdb_starter does no longer see the file, it will not be restarted.

Tested with

  • Oracle 10, 11, 12, 18, 19 RAC and single instance databases(probably also running on older versions)
  • Oracle asm, apx instances
  • Oracle plugin/multitenant databases
  • Oracle primary and standby databases
  • SAPhana 2
  • SQL Server 2008(10), 2012(11), 2016(13)
  • cockroachDB 2
  • db2 10,11
  • mysql 5, 8
  • postgres 9, 10, 11, 12

Help needed with the SAPhana integration.

zbxdb is very cluster aware and will monitor the full cluster using a single connection to a single instance and monitor all databases served by that instance.

Create a separate host for every Oracle database in zabbix(not for every instance of a RAC). Create a separate host for every mssql instance in zabbix(not for every datbase served by that instance). Make sure that your hostname in the zbxdb.XXX.cfg is listed exactly like in the zabbix GUI (case sensitive)

getting started

trouble shooting

de-installation

encryption of passwords

Adding more db support

Very simple: give the dbtype a name and select a driver name for it. Ad the {dbtype}.py to the dbconnections / module that should handle the database connection. Add the {driver}.py to the drivererrors / module that should handle exceptions and give a uniform format to zbxdb.py. Add the {dbtype} / directory to the etc/zbxdb_checks / directory and write the sql tests files for it. Currently Oracle has the most complete set. The idea is that the script detects which role the database has(primary/slave/standby) and loads the {role}.{mainversion}.cfg file where the sqls are written.

The sql's should return key/value pairs. In the template everything is written from an Oracle starters point and similar queries are defined for mssql and postgres, both using the same template, item prototypes and triggers.

Did you create and test/use a new set of queries for a version or for a database not yet listed, please, feel free to share them, to make the supported list bigger. The fact that I did not list them here does not mean it can't be done. It just means that I have no access to them(and also no immediate need) but I would be happy to add.

usage zbxdb.py - c configfile resulting in log to stdout and datafile in specified out_dir/{configfile}.zbx

  • bin/zbxdb.py
  • bin/zbxdb_sender
  • bin/zbxdb_sender.py
  • bin/zbxdb_starter

contributions / pull requests are VERY welcome

please, make sure that if you contribute, that you don't add queries that require an extra license, like Oracle diagnostics or tuning packs. Also, add the additions to all versions possible so the checks are a bit consistent over the releases (if possible)

database config files examples

It is important to note that the hostname parameter in the configuration files reflects the hostname that is created in zabbix (case sensitive). The idea is that every configuration points to it's own and unique hostname so you have as much different hostnames in zabbix as zbxdb.*.cfg files. Attach the zbxdb template to the host[s] and all should work. In this setup, a host is a database configuration and not a machine that hosts a database.

default checks files

They consist of sections. Every section has a parameter minutes that specifies after how many minutes the queries will have to be run again.

section with 'discover' in their name have a special meaning, the return json arrays to zabbix for the low level discovery. The other sections just contain queries returning key/value pairs.

Do you find a version of a database that is not -yet - in the list, start with a copy of the highest previous version and include the version number in the name as above. The checks really are nothing more that queries that return key/value pairs to be sent to zabbix. You need to be sure that

  • your db_driver is listed in bin/drivererrors/
  • your db_type is listed in bin/dbconnections/
  • your db_type is listed as directory in checks_dir/
  • your db_type has a checks file for your version db in checks_dir/primary.{version}.cfg

drivererrors and dbconnections are loaded dynamically, based on the db_driver and db_type parameters.

site checks files - examples

working of zbxdb.py

Assuming bin / is in PATH: When using this configfile(zbxdb.py - c etc/zbxdb.odb.cfg) zbxdb.py will read the configfile and try to connect to the database using db_url If all parameters are correct zbxdb will keep looping forever. Using the site_checks as shown, zbxdb tries to find them in `checks_dir/db_type/sap.cfg and in checks_dir/db_type/ebs.cfg(just specify a comma separated list for this if you have multiple files) Outputfile containing the metrics is created in out_dir/zbxdb.odb.zbx

After having connected to the specified service, zbxdb finds out the instance_type and version, after which the database_role is determined, if applicable. Using these parameters the correct checks_dir/db_type/{role}.{version}.cfg file is chosen. For a regular database this translates to 'primary.{version}.cfg'

After having read the checks_files, a lld array containing the queries is written before monitoring starts. When monitoring starts, first the * discovery * section is executed. This is to discover the instances, tablespaces, diskgroups, or whatever you want to monitor.

zbxdb also keeps track of the used queries. zbxdb executes queries and expects them to return a valid zabbix_key and values. The zabbix_key that the queries return should be known in zabbix in your zabbix_host(or be discovered by a preceding lld query in a * discover * section)

If a database goes down, zbxdb will try to reconnect until killed or the cfg file is removed. When a new connection is tried, zbxdb reads the config file, just in case there was a change. If a checks file in use is changed, zbxdb re-reads the file and logs about this.

zbxdb's time is mostly spent sleeping. It wakes-up every minute and checks if a section has to be executed or not. Every section contains a minutes: X parameter that specifies how big the monitor interval should be for that section. The interval is specified in minutes. If at a certain moment multiple sections are to be executed, they are executed all after each other. If for some reason the checks take longer than a minute, an interval is skipped.

The idea for site_checks is to have application specific checks in them. The regular checks should be application independent and be generic for that type and version of database. For RAC databases, just connect using 1 instance For pluggable database, just connect to a common user to monitor all plugin databases.

zbxdb.py should be restarted if it accidentally crashes, what very rarely happens. On * nix the zbxdb_starter takes care for starting all instances of zbxdb.py, with a 1 second delay. On Windows zbxdb.py could be implemented as a service that auto starts.

Enclosed tools:

zbxdb_starter

this is an aide to[re]start zbxdb in an orderly way. Put it in the crontab, every minute. It will check the etc directory(note the lack of a leading '/') and start the configuration files named etc/zbxdb.{your_config}.cfg, each given their own logfile. Notice the sleep in the start sequence. This is done to make sure not all concurrently running zbxdb sessions awake at the same moment. Now their awakenings is separated by a second. This makes that if running 10 monitors, they are executing their checks one after an other. Schedule this in the crontab, every minute. Make sure that ZBXDB_HOME is defined in your .bash_profile and also add the location of zbxdb.py to your PATH. In my case: PATH =$HOME/zbxdb/bin: $PATH

zbxdb_stop

Just to stop all currently running zbxdb.py scripts for the user.

zbxdb_sender.py

this is used to really send the data to zabbix. Could be zabbix server, could be zabbix proxy, only depending on the location of your monitoring host. It collects the files from the out_dir and sends them in one session. Doing so makes the process pretty efficient, at the cost of a small delay. zbxdb_sender.py - c / etc/zabbix/zabbix_agentd.conf - z zbxdb_out Uses the agent configuration and makes it possible to use encryption. Using the agent configuration uses the ServerActive adresses to send the data to Schedule this in the crontab, every minute.

zbx_discover_oradbs.py

It should be able to also discover windows machines. Requirement for that is that the remote powershell service is running. Assuming ssh is configured with keys.

configuration file - csv file with header:

site;cluster;alert_group;protocol;user;password;password_enc;members
cust01;;prod_alerts;ssh;;;srv-db-01
cust01;prod01;prod_alerts;ssh;;;prod0101,prod0102,prod0103
cust01;;;rdp;oracle;secret;win00
cust01;;;rdp;oracle;verysecret;win01
cust01;;;rdb;oracle;unknown;wclu01,wclu02,wclu03

zbx_alertlog.py

A python script that is supposed to run on the Oracle database server. It connects to all detected instances, reads the v$diag_info for the correct log.xml location. zbx_alertlog.py also checks for existence of the log.xml and creates an empty file if it does not -yet - exist - anymore-. Since the zabbix agent that is going to read the alert log.xml runs in the zabbix account and not oracle, permissions are modified to 744. The lld array is sent to zabbix using zabbix_sender(and written to zbx_alertlog.lld)

usage: zbx_alertlog.py[-h][-o ORATAB][-s SERVERNAME][-p PORT] - H HOSTNAME - k KEY

modules

drivererrors

Drivererrors has 2 entries:

  • db_errorcode(driver, excep)
  • db_error_needs_new_session(driver, code)

db_errorcode

returns the errorcode and text it got from excep.

db_error_needs_new_session

returns True if with the given code it is useless to try to continue the current session. I oracle, for example 3113 is a good reason to forget the session and to try to connect again. Every driver has

dbconnections

dbconnections has 3 entries:

  • connection_info(con)
  • connect_string(config)
  • connect(db, c)

connection_info

Has to fill info about the connected database like

  • dbversion
  • sid
  • serial
  • instance_type
  • iname
  • uname
  • db_role

connect_string

returns the connect string needed to connect to the database.

connect

performs the actual connect to the database using the configuration parameters.

auto database discovery for Oracle

prepare a host with a discovery rule 'oradb.lld' of type zabbix_trapper. Give the discovery rule a host prototye "{#DB_NAME}" and add it to groups you need, but also to group prototypes "{#GROUP}" and "{#ALERT}". The alert group is optional but is meant to be for ... alerting. Add the zbxdb template to the host prototype. Set the inventory to automatic.

zbx_discover_oradbs is the - bash - script that does the discovery. It needs host equivalence for all machines that you want to be discovered. zbx_discover_oradbs visits all hosts and uses lsnrctl to find all instances. It uses the common conventions regarding instance and database naming. It works for single database and for RAC databases.

the configuration file:

# site_prefix (clustername|"") host[s]
prefix cluster01 clu01node01 clu01node02
prefix cluster02 clu02node01 clu02node02
prefix "" singlehost1
# for alerting based on a group:
alert_pattern = (cluster01_ | PB$)
# pattern matches hostnames that contain cluster01_ or end on PB
alert_group = your_generated_alert_group

the usage: zbx_discover_oradb hostname_with_the_oradb.lld_key[zabbix_(server | proxy)]

Since zbxdb template contains a nodata trigger for every database, expect that after a few minutes a missing data alert is raised, if you did not also start zbxdb.py for the newly discovered database[s].

a file is created that contains the discovery json array that is sent to zabbix. a file is created in the / tmp / directory of every host that is visited for the discovery. It is the remote discovery script.

sample output file:

testhost oradb.lld 1548959488 rotra_srv-yum-001 oradb.lld 1551257701 {"data": [
    {"{#DB_NAME}": "prefix_cluster01_CTEST1P", "{#GROUP}": "prefix_cluster01", "{#ALERT}": "your_generated_alert_group"}, {"{#DB_NAME}": "prefix_cluster01_DBFS1P", "{#GROUP}": "prefix_cluster01", "{#ALERT}": "your_generated_alert_group"}, {"{#DB_NAME}": "prefix_cluster01_RONR", "{#GROUP}": "prefix_cluster01", "{#ALERT}": "your_generated_alert_group"}, {"{#DB_NAME}": "prefix_cluster01_TRANS", "{#GROUP}": "prefix_cluster01",
                                                                                                                                                                                                                                                                                                                                                                   "{#ALERT}": "your_generated_alert_group"}, {"{#DB_NAME}": "prefix_cluster02_CTEST1PB", "{#GROUP}": "prefix_cluster02", "{#ALERT}": "your_generated_alert_group"}, {"{#DB_NAME}": "prefix_cluster02_CTEST2A", "{#GROUP}": "prefix_cluster02"}, {"{#DB_NAME}": "prefix_cluster02_PTVLO", "{#GROUP}": "prefix_cluster02"}, {"{#DB_NAME}": "prefix_cluster02_TRANS", "{#GROUP}": "rprefix_cluster02"}, {"{#DB_NAME}": "prefix_CC12", "{#GROUP}": "prefix"}
]}

Just in case you already have added lot's of databases manually, you can put them in an ignore list so you won't get lot's of errors during the processing of the discovery data in zabbix. Just put the generated hostnames that you want to ignore in $HOME/etc/zbx_discover_oradbs.ignore, next to the cfg file.

zabbix is not very flexible regarding group prototypes. The group names that are generated are not allowed to pre-exist(v4) Sorry for that, we have to deal with that.

Warning:

Use the code at your own risk. It is tested and seems to be functional. Use an account with the least required privileges, both on OS as on database level. Especially Oracle has good options to limit the required privileges. On others you still might need special privileges to access the system's tables/views. Sadly enough, for some databases you still need a database super user type of account to be able to access the needed tables/views.

Don't use a dba type account for this. Read only access is good enough

Don't use a root account for this. Any OS user that can use zabbix-sender will do Using high privileged accounts is not needed in Oracle.

upgrading

Normally is is enough to just overwrite zbxdb.py with the new copy. The running instance will notice the change and reload it without any problems.

v2.0 -- logging module introduced

When coming from v1, the upgrade to v2 has to be prepared by putting a logging.json in your ZBXDB_HOME/etc / folder. If that is in place the upgrade will be a smooth as before, otherwise zbxdb.py will fallback to a default logging configuration, to stdout. No problem at all but since v2 logging is properly introduced and has more options to configure. To make the best of it, it is best to completely stop the running instances of zbxdb.py, because zbxdb_starter opens with output redirection to stdout and that could give slightly confusing messages like msg M2 with timestamp t+1 appearing sooner than msg M1 with timestamp t

v3.0 -- real encryption introduced

Coming from V2 this should not give any headaches, other than a requirement that in many cases is already fullfilled. (cryptography)

database user creation:

Oracle classic

create user cistats identified by knowoneknows
grant create session, select any dictionary, oem_monitor to cistats

Oracle multitenant

In Oracle 12 or later - when using pluggable database, in the root container, create a common user:

create user c##cistats identified by knowoneknows;
alter user c##cistats set container_data = all container = current;
grant create session, select any dictionary, oem_monitor, dv_monitor to c##cistats;

SQLserver

create login and user to monitor with low privs in all databases(including model)
USE[master]
GO
CREATE LOGIN[CISTATS] WITH PASSWORD = N'knowoneknows', DEFAULT_DATABASE = [master], CHECK_EXPIRATION = OFF, CHECK_POLICY = OFF
GO
GRANT VIEW SERVER STATE TO[CISTATS]
GO
USE[msdb]
GO
EXEC master.dbo.sp_MsForEachDB 'USE [?]; CREATE USER [CISTATS] FOR LOGIN [CISTATS];'
GO
use msdb
EXEC sp_addrolemember N'SQLAgentReaderRole', N'CISTATS'
EXEC sp_addrolemember N'SQLAgentUserRole', N'CISTATS'
GO
GRANT SELECT on sysjobs to[CISTATS]
GRANT SELECT on sysjobhistory to[CISTATS]
grant select on sysjobactivity to[CISTATS]

postgreSQL

create extension dblink
In order to be able to create a dblink, the contrib package must be installed on the dbserver[s](postgresql9*-contrib).

for collecting total dead and live tuples per database a temporary table and a dblink is used. The queries for this collection use a construction for which postgres - sadly enough - requires superuser to do that without password.
I am very open for tips to make this better, without a superuser account.

v9:
create user cistats with superuser encrypted password 'knowoneknows'
or, without superuser:
create user cistats with encrypted password 'knowoneknows'
grant select on pg_catalog.pg_settings to cistats;

v10 and later:
create user cistats with encrypted password 'knowoneknows'
GRANT pg_read_all_settings TO cistats
GRANT pg_monitor to cistats
GRANT TEMPORARY on DATABASE postgres TO cistats

If you need statistics like live/dead tuples per database a dblink is used. To use this without password the
user needs to be superuser. Sad enough.
alter user cistats with superuser

mysql

grant SELECT, REPLICATION CLIENT, SHOW DATABASES, SUPER, PROCESS
ON * .*
TO  'cistats'@'localhost'
IDENTIFIED BY 'knowoneknows'

zbxdb's People

Contributors

0fca avatar ikzelf avatar julianobarbosa avatar luiscontrerasdo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zbxdb's Issues

ASM cluster monitoring configuration

Could you please describe how to properly monitor Oracle ASM instances in the cluster environment?
ASM instances are not registered in the high availability SCAN listener, so I have to specify hostname to one of cluster's node in db_url parameter. Script in this case receives the status for all ASM instances in normal situation. But, if this host become unavailable, data will no longer be updated, even while another nodes instances still online.
At the same time, I can’t add several cfg files and zabbix hosts, one for each node of the cluster, because in this case the metrics and triggers will be duplicated, and events will also cause doubles.
Is it possible to use some kind of failover mechanism for the database connection string, or is some other ASM monitoring logic supposed to be?

zbxdb_sender.py and zbxdb_sender

Hi.
Currently there is two scripts zbxdb_sender.py and zbxdb_sender to send logs to zabbix server.
They seem to do similar things, so perhaps zbxdb_sender bash script should be retired?

ModuleNotFoundError: No module named 'sqlparse'

Hi,

I have installed zbxdb using the getting started
but when I try to run it (zbxdb.py) I get this error 👍

Traceback (most recent call last):
File "./zbxdb/bin/zbxdb.py", line 36, in
import sqlparse
ModuleNotFoundError: No module named 'sqlparse'

but pip list give me :
sqlparse (0.3.1)

(server is ubuntu 18.04)

thanks for your help

What is difference between db_url and hostname in zbxdb.ms.cfg?

Requesting a documentation enhancement describing the difference and correct usage of the zbxdb config lines db_url, server, and hostname.

I currently set "db_url" to the local zabbix database, in my case a MySQL database named "zabbix" residing on localhost.
db_url = //localhost/zabbix

I have set "server" to the monitored database server name or IP. Below is an example of an Azure SQL name.
server = tc3vmdevdb4.database.windows.net

I have set "hostname" to the Zabbix configured hostname used for matching Zabbix configuration to the ZBXDB generated database statistics.
hostname = tc3vmdevdb4

While I am fairly certain that my usage of server and hostname are correct, I need to better understand db_url. I do see some errors below which I am trying to better understand as some of my Azure databases do not have a physical host (I implemented pyodbc to connect to Azure SQL and managed instance databases).
WARNING:main:(1.311)connection error: [0] 42000 for zabbix_stat@//localhost/zabbix

ZBXDB-1013: Db execution error: ORA-01013: ???????????

Hi
when I run the zbxdb.py with config file, The output contains success and also failure outputs, the errors seems, to be for frequency of mission planning and frequency of Sql execution,
the error is:
"
WARNING:main:zbxdb cancel_sql checks_60m p_ts
WARNING:main:zbxdb canceled checks_60m p_ts
INFO:main:key=checks_60m.p_ts ZBXDB-1013: Db execution error: ORA-01013: ???????????
"
Sql execution time is about 1 to 2 minutes, the frequency of the mission plan I try to set to 1 or 2, it will go wrong (ZBXDB-1013).
How can I set the frequency of the above two?
Thank you, I look forward to your reply.

How to configure zbx_alertlog.py

Hello, Ronald.
I want to configure zbx_alertlog.py. I don`t understand how to do it.

Do I need to install zabbix agent on DB host?
What is it installed python version on DB host?
Do I need to clone zbxdb projects on DB hosts?

problems with postgresql monitoring

Hi

I download the latest version of zbxdb and try to check the postgres where my zabbix is running - but I get an error and don't know what it's about. Could you please help?

To Reproduce
Steps to reproduce the behavior:
1.

[zbxdb]
db_url = xx.xxx.xxx.xxx:5432/zabbix
username = zabbix
password =
db_type = postgres
instance_type = rdbms
db_driver = psycopg2
role = normal
out_dir = $HOME/zbxdb_out
hostname = predix-mon-01
checks_dir = etc/zbxdb_checks
site_checks = NONE
sql_timeout = 3
password_enc = emFiYml4
  1. driver version
Package      Version
------------ ----------
certifi      2019.11.28
cffi         1.14.0
chardet      3.0.4
cryptography 2.8
cx-Oracle    7.3.0
ibm-db       3.0.1
idna         2.9
ntlm-auth    1.4.0
pip          20.0.2
psycopg2     2.8.4
pycparser    2.20
PyMySQL      0.9.3
pyOpenSSL    19.1.0
pypsrp       0.4.0
python-tds   1.10.0
requests     2.23.0
setuptools   39.0.1
six          1.14.0
sqlanydb     1.0.10
sqlparse     0.3.1
urllib3      1.25.8
  1. db version
    postgres (PostgreSQL) 11.6

logs

2020-03-23 15:16:02,224___main___50_problem
Traceback (most recent call last):
  File "/home/zbxdd/zbxdb/bin/zbxdb.py", line 404, in main
    connect_info = db_connections.connection_info(_conn)
  File "/home/zbxdd/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/zbxdd/zbxdb/bin/zbxdb.py", line 820, in <module>
    main()
  File "/home/zbxdd/zbxdb/bin/zbxdb.py", line 785, in main
    err_code, err_msg = driver_errors.db_errorcode(db_driver, dberr)
  File "/home/zbxdd/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'

ModuleNotFoundError: No module named 'dbconnections.pytds'

hi Ronald,when monitoring the sqlserver database with zbxdb, I encountered the following error:
"
2019年 07月 13日 星期六 23:27:02 CST Starting etc/zbxdb.ms_2_206.cfg
INFO:main:start python-3.6.5 zbxdb-2.01 pid=17303 Connecting ...

INFO:main:zbxdb found db_type=msssql, driver pytds; checking for driver

INFO:main:<module 'pytds' from '/home/zbxdb/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pytds/init.py'>
INFO:main:zbxdb driver pytds loaded

INFO:main:zbxdb driver drivererrors for pytds loaded

CRITICAL:main:Failed to load dbconnections routines for msssql

CRITICAL:main:Looked in ['/home/zbxdb/zbxdb/bin', '/home/zbxdb/.pyenv/versions/3.6.5/lib/python36.zip', '/home/zbxdb/.pyenv/versions/3.6.5/lib/python3.6', '/home/zbxdb/.pyenv/versions/3.6.5/lib/python3.6/lib-dynload', '/home/zbxdb/.pyenv/versions/3.6.5/lib/python3.6/site-packages']
Traceback (most recent call last):
File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 238, in load_db_connections
"dbconnections." + _c['db_type'])
File "/home/zbxdb/.pyenv/versions/3.6.5/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'dbconnections.msssql'
CRITICAL:main:problem
Traceback (most recent call last):
File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 794, in
main()
File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 303, in main
db_connections = load_db_connections(_config)
File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 238, in load_db_connections
"dbconnections." + _c['db_type'])
File "/home/zbxdb/.pyenv/versions/3.6.5/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'dbconnections.msssql'

"
The contents of the .cfg file are as follows:
"
[zbxdb]
db_url = //172.16.2.206/MSSQLSERVER
username = zbxdb
password =
db_type = msssql
server = hostname.domain
server_port = 1433
db_name = master
db_driver = pytds
role = normal
out_dir = $HOME/zbxora_out
hostname = testhost
checks_dir = etc/zbxdb_checks
site_checks = NONE
instance_type = rdbms
password_enc = U3FsMjAxOQ==
"
The pytds module has been successfully installed and tested as follows:
"
[zbxdb@dhec-vm-264 etc]$ python
Python 3.6.5 (default, Jul 12 2019, 16:13:21)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.

import pytds

"
How can I analyze and resolve this issue?
Thank you, I look forward to your reply.

I don`t connect to Postgresql 9

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,559___main___30_start python-3.6.5 zbxdb-2.07 pid=125661 Connecting ...

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

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

2020-06-23 16:59:12,900___main___50_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,611___main___30_start python-3.6.5 zbxdb-2.07 pid=126251 Connecting ...

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

2020-06-23 17:00:12,670___main___50_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,728___main___30_start python-3.6.5 zbxdb-2.07 pid=126848 Connecting ...

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

2020-06-23 17:01:12,784___main___50_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]$

Trouble using zbxdb_sender

Hi,

I have trouble using zbxdb_sender.
simply running zbxdb_sender gives me default info:

Usage zbxdb_sender ZBXDB_OUT
   to collect outputs from that directory to send to zabbix
   using $HOME/zbxdb_sender directory for work space
   using $HOME/log for log directory
   PLEASE do not run zbxdb processes as root

So, trying to use it with ZBXDB_OUT, like this: zbxdb_sender zbx_pss-ora_out gives me output below:

/home/zbxdb/zbxdb/bin/zbxdb_sender: line 47: /home/zbxdb/log/zbxdb_sender.Wed.log: No such file or directory
find: ‘/home/zbxdb/log/zbxdb_sender.*.log’: No such file or director

Output of ls -l zbx_pss-ora_out/ is:

-rw-rw-r-- 1 zbxdb zbxdb 27318 Sep  5 15:27 zbxdb.pss-ora.zbx

while the only log directory is empty:

ls -l zbxdb/log/
total 0

In the same time only log file is in zbxdb_sender directory:

ls -l zbxdb_sender/in/
total 160
-rw-rw-r-- 1 zbxdb zbxdb   6624 Sep  5 15:05 zbxdb.pss-ora.cfg.log
-rw-rw-r-- 1 zbxdb zbxdb 143928 Sep  5 15:22 zbxdb.pss-ora.zbx
-rw-rw-r-- 1 zbxdb zbxdb   2335 Sep  5 14:05 zbxdb_starter.log

Home directory for zbxdb user looks like this:

ls -l
total 16
drwxrwxr-x 3 zbxdb zbxdb 4096 Sep  5 11:11 oradiag_zbxdb
drwxrwxr-x 2 zbxdb zbxdb 4096 Sep  5 15:23 zbx_pss-ora_out
drwxrwxr-x 7 zbxdb zbxdb 4096 Sep  5 15:10 zbxdb
drwxrwxr-x 4 zbxdb zbxdb 4096 Sep  5 13:19 zbxdb_sender

I'm using zbxdb_starter in cron, set to fire up every minute (like in readme), and my config file looks like this:

db_url = //hostname/DBPROD
username = zbxmon
password =
db_type = oracle
db_driver = cx_Oracle
instance_type = rdbms
role = normal
out_dir = /home/zbxdb/zbx_pss-ora_out
hostname = pss-ora
checks_dir = /home/zbxdb/zbxdb/etc/zbxdb_checks
site_checks = sap,asm.11
password_enc = somethinghere

Tool looks very nice, connects to instance and writes data nicely to zbxdb.pss-ora.zbx file, but I might be bit too rusty for current documentation. Makes me think I'll have to make some blog post about it (or submit some detailed documentation for newbies, if You wish).

Monitoring ODA and ACFS

Hello,
I have an ODA (Oracle Database Appliance), which uses ACFS.

Would it be possible to create some monitoring for ACFS and ODA ?

send data to Zabbix server

as far as I know mechanism to send collected data to Zabbix server is zbxdb_sender, what process is invoking sender to send data to zabbix?
when data is sent to database?
I can not find any data in my zabbix server from my monitored database
Thanks

Oracle DB Discovery Script

I have a single server which hosts multiple database instances (Oracle 11), I have been trying to use the zbx_discover_oradbs script to identify them all but I have run into a couple of issues.

  1. pseudo-terminal will not be allocated because stdin error is generated running the script. Have added -T to the ssh connection string in zbx_discover_oradbs.py to get round this.

  2. When the script runs it prints : error member server01: 0, {"data":[]}. The cfg is setup as test;;alerts;ssh;username;;;server01

I have put some print statements through zbx_discover_oradbs.py and I can see lsnrctl is being called and the service data is returned but this isn't being converted into a JSON. I'm a a bit of a loss any thoughts?.

Also just to confirm, when multiple DBs are on a single host, each database instance should be a separate host item in zabbix. you cant have multiple databases reporting to a single host. Have tried this and zabbix seems to get quite confused over the data. Thanks

error in site check scripts

Hi
when I run the zbxdb.py with config file, The output contains success and also failure outputs, the errors seems, to be for ebs and sap scripts,
also my sap.cfg is empty
I created the user just as you said in readme file
the error is:
2019-01-15 18:26:49.248613 key=ebs_10m.ebs.concmgr ZBXDB-942: Db execution error: ORA-00942: table or view does not exist
2019-01-15 18:26:49.250093 key=ebs_10m.ebs.paul.truncatp ZBXDB-942: Db execution error: ORA-00942: table or view does not exist
2019-01-15 18:26:49.251452 key=ebs_60m.concmanager ZBXDB-942: Db execution error: ORA-00942: table or view does not exist
2019-01-15 18:26:49.252778 key=ebs_discovery_60m.ebs.concmanager ZBXDB-942: Db execution error: ORA-00942: table or view does not exist
2019-01-15 18:26:49.255618 key=ebs_startup.ebs.bagger ZBXDB-942: Db execution error: ORA-00942: table or view does not exist

Multiple DB's on same machine create flapping alerts

Describe the bug
I have a few machines where I run 4-5 oracle databases on the machine, and monitor them all with zbxdb. There are two alerts in particular that are causing issues for me.

  1. The rman alerts. If one db has been backed up, but say the other three have not, the autodiscovery runs, and adds for machine "machinename" an item like rman[FULL]. However, all the other db's on the machine also add an rman[FULL], so the first db says "last backup 2 years ago" and the other three spit out zeros, and the alert flaps every 20 minutes..

  2. zbxdb cannot connect. If you have multiple db's, or more commonly for me, a db and an ASM instance. When the ASM instance is up, but the db is down (or bad credentials, or whatever), the alert gets alternating data. up/down/up/down/up/down and flaps like mad.

To Reproduce
Steps to reproduce the behavior:

  1. Multiple DB's on same server, all wired to same "host" in zabbix
  2. 0.79
  3. oracle 12c
  4. zabbix 4.0.4
  5. NA

Expected behavior
The rman and zbxdb cannot connect LLD needs to add some key that ties it to a specific DB or instance, so they don't overwrite one another every time the lld runs, and create flapping alerts

logs
NA

monitoring platform:
Zabbix 4.0.4
Python 3.5

Additional context
NA

How to set db info with none default port in zbxdb config file ?

[zbxdb]
db_url = //localhost/fsdb01
username = postgres
password =
db_type = oracle
db_driver = cx_Oracle
instance_type = rdbms
role = normal
out_dir = $HOME/zbxora_out
hostname = testhost
checks_dir = etc/zbxdb_checks
site_checks = sap,ebs
password_enc = cjB0cjAwdA==

Is there a filed to set the port if the db not using defautl port? thanks!

ValueError when trying to run zbxdb.py

Describe the bug
I am trying to run zbxdb against the configuration file and it fails with ValueError

To Reproduce
Steps to reproduce the behavior:

  1. cfg file obfuscate entries like address, username and password
[zbxdb]
db_url = //192.168.100.103/MSSQLSERVER
username = zabbix
password = zabbix
db_type = mssql
server = 192.168.100.103
server_port = 1433
db_name = master
db_driver = pytds
role = normal
out_dir = $HOME/zbxdb_out
hostname = testhost
checks_dir = etc/zbxdb_checks
site_checks = NONE
cafile = $HOME/somecapemfile
instance_type = rdbms
password_enc = emFiYml4

Expected behavior
No error

logs

~/zbxdb/zbxdb/bin/zbxdb.py -vc zbxdb.ms.cfg
Falling back to default logging config
WARNING:__main__:Changing loglevel from 20 to 10
DEBUG:__main__:log level 10
WARNING:__main__:start python-3.6.8 zbxdb-2.07 pid=24746 Connecting ...

WARNING:__main__:zbxdb found db_type=mssql, driver pytds; checking for driver

CRITICAL:__main__:problem
Traceback (most recent call last):
  File "/var/lib/zabbix/zbxdb/zbxdb/bin/zbxdb.py", line 832, in <module>
    main()
  File "/var/lib/zabbix/zbxdb/zbxdb/bin/zbxdb.py", line 315, in main
    " does not exist in the "+_config['checks_dir']+" directory")
ValueError: db_type mssql does not exist in the etc/zbxdb_checks directory

mssql /does/ exist in etc/zbxdb_checks

ls -l zbxdb_checks
total 4
drwxr-xr-x. 2 zabbix zabbix   27 Sep  2 19:40 cockroach
drwxr-xr-x. 2 zabbix zabbix   28 Sep  2 19:40 db2
drwxr-xr-x. 2 zabbix zabbix   72 Sep  2 19:52 mssql
drwxr-xr-x. 2 zabbix zabbix   48 Sep  2 19:40 mysql
drwxr-xr-x. 2 zabbix zabbix 4096 Sep  2 19:40 oracle
drwxr-xr-x. 2 zabbix zabbix  130 Sep  2 19:40 postgres

Items of group "objects" in zbxdb_template_v4 for ORACLE 11 don't collect data

Hello,
Items of group "objects" in zbxdb_template_v4 for ORACLE 11 don't collect any data.

oracle database 11,
db_type = oracle
db_driver = cx_Oracle
instance_type = rdbms
role = normal

For example, zbxdb_template_v4 waits data with key:
objects[{#PDB},{#SCHEMA},INVALID,count]
but script in
etc\zbxdb_checks\oracle\primary.11.cfg

obj.stat: with all_status as
(
select 'INVALID' status from dual
union all
select 'VALID' status from dual
)
, schemas as
(
select distinct s.owner, a.status
from dba_objects s
cross join all_status a
)
select 'objects[,' | | a.owner | |',' | | a.status | |',count]', count(obj.status)
from schemas a
left join dba_objects obj
on(a.status=obj.status
and a.owner=obj.owner)
group by a.status, a.owner

In result: first parameter is empty

I think that right script is:

obj.stat: with all_status as
(
select 'INVALID' status from dual
union all
select 'VALID' status from dual
)
, schemas as
(
select distinct s.owner, a.status
from dba_objects s
cross join all_status a
)
select 'objects[' | | d.name | | ',' | | a.owner | |',' | | a.status | |',count]', count(obj.status)
from schemas a
left join dba_objects obj
on(a.status=obj.status
and a.owner=obj.owner)
, v$database d
group by a.status, d.name, a.owner

It works for me.

Inaccurate documentation of config file / zbxdb.py returns error

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 password_enc 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

ASM 10g

Hi, I've adapt a cfg file to work with ASM on 10g.
I put the file etc/zbxdb_checks/oracle/asm.10.cfg

And now? How to add this configuration to the zbxdb software?
Thanks

detect promotion from slave to master during a session

currently zbxdb determines the role of the database only during the setup of a session. A Postgres slave can be promoted to master without interrupting the session. It would be nice to have zbxdb detect this change during the run so it can start monitoring the master right away.

Maybe it is good enough to just stop the session and do a re-connect where the correct role is found?

Undocumented binaries

Currently it is bit unclear what these scripts are doing;

tnslsnr-ping.py
zbx_agent.sh
zbx_discover_lsnr.py
zbx_exaserver.sh
zbx_odaserver.sh

Previous run still running error

Hi, I got this error some minutes after start the script:

2020-10-19 09:39:03,216___main__ Logging in /home/zbxdb/log/zbxdb_sender.log
2020-10-19 09:39:03,217___main__ Namespace(cfile='/etc/zabbix/zabbix_agentd.conf', verbosity=0, zbxdb_out='zbxora_out')
2020-10-19 09:39:03,217___main__ 2020-10-19-0939 previous run still running(or crashed(lock file: /home/zbxdb/zbxdb_sender/zbxdb_sender.lock))

I've tried to stop all, kill the process, remove the lock file but, after restart, I've got the same results.
Can you help me?
Thanks

restart because of changed script ... while it is NOT changed

Describe the bug
This log messages shows the modification date of zbxdb.py did not change and tells otherwise:
2019-03-03 16:52:07.840274 /home/zabbixa/zbxdb/bin/zbxdb.py changed, from Fri Mar 1 11:18:09 2019 to Fri Mar 1 11:18:09 2019 restarting ...
To Reproduce
intermittent, not able to reproduce at will
Expected behavior
Since the last modification date of the script did not change, it should not be logged and zbxdb.py should not be auto restarted.
logs
2019-03-03 16:19:07.694104 connect 2 times, 1 fail; started 12361 queries, 0 fail memrss:14532 user:31.939144 sys:8
.330733
2019-03-03 16:52:07.840274 /home/zabbixa/zbxdb/bin/zbxdb.py changed, from Fri Mar 1 11:18:09 2019 to Fri Mar 1 11:18:09 2019 restarting ...

monitoring platform:

  • Oracle Enterprise Linux 6.4
  • Python 3.6.4
  • drivers of Oracle and mssql

Additional context
All instances of zbxdb.py on this machine make the same log at about the same time.
On an other machine with the same version of zbxdb.py this does not occur. (Python 3.6.5)

How to use zbxdb config file

Hi
I tried to use oracle sample config file, as below, but faced problem (I used my url ...).
[zbxdb]
db_url = //localhost/fsdb01
username = postgres
password =
db_type = oracle
db_driver = cx_Oracle
instance_type = rdbms
role = normal
out_dir = $HOME/zbxora_out
hostname = testhost
checks_dir = etc/zbxdb_checks
site_checks = sap,ebs
password_enc = cjB0cjAwdA==

a few questions
why user name is postgres...
what is password_enc? what should I fill in it?
when I entered my password in password field and user (instead of postgres), I got following error:
Traceback (most recent call last):
File "/usr/local/bin/zbxdb.py", line 159, in
config = get_config(ARGS.configfile)
File "/usr/local/bin/zbxdb.py", line 132, in get_config
enc = encrypted(config['password'])
File "/usr/local/bin/zbxdb.py", line 59, in encrypted
return base64.b64encode(bytes(plain, 'utf-8'))
TypeError: str() takes at most 1 argument (2 given)

ModuleNotFoundError: No module named 'sqlparse'

Hi, after installation and configuration I got this error in zbxdb_starter.log:

Wed 14 Oct 2020 12:57:01 PM CEST Starting etc/zbxdb.odb.cfg
Traceback (most recent call last):
  File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 36, in <module>
    import sqlparse
ModuleNotFoundError: No module named 'sqlparse'

Pyton is properly configured (I suppose):

$ type python
python is /home/zbxdb/.pyenv/shims/python

$ pip install sqlparse
Requirement already satisfied: sqlparse in /home/zbxdb/.pyenv/versions/3.6.5/lib/python3.6/site-packages

Whats wrong?
Thanks a lot
Stefano

Unified logging

zbxdb.py uses python logger class, whereas zbxdb_sender.py has internal mechanism (print to file thats in $home/log)

Perhaps zbxdb_sender.py should also use logger?

Need ZabDash queries

What are the SQL queries used to populate the ZabDash dashboard, ie Triggers by host - Top 10 and Triggers by Severity? I am having trouble identifying why I have numbers displayed when I have no active issues. Also, from what script are these queries executed? Thank you

TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

hi Ronald,when monitoring the sqlserver database with zbxdb, I encountered the following error:
"
2019-07-14 18:04:01.972193 user CISTATS CISTATS sid,serial 0,0 instance DHEC-VM-74 as normal cancel:False

INFO:main:using checks from ['etc/zbxdb_checks/mssql/primary.11.cfg']

INFO:main:checks loading etc/zbxdb_checks/mssql/primary.11.cfg

CRITICAL:main:file etc/zbxdb_checks/mssql/primary.11.cfg has parsing errors ->(13)

CRITICAL:main:problem
Traceback (most recent call last):
File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 794, in
main()
File "/home/zbxdb/zbxdb/bin/zbxdb.py", line 539, in main
sec_mins = int(_checks.get(section, "minutes"))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
"
How can I analyze and resolve this issue?
Thank you, I look forward to your reply.

zbxdb - connect no data

Describe the bug
from time to time some zbxdb connections to oracle db freezes with the message connect no data at zabbix monitor.
From zbx proxy looks all good, processes are running but no data are received. The only solution is kill the desired process a
wait to be started again.

PROBLEM srvzrorgDB01-SKOLMMCP zbxdb Connect nodata srvzrorgDB01-SKOLMMCP since 30m

To Reproduce
Steps to reproduce the behavior:
1.
zbxdb.srvzrorgDB01-SKOLMMCP.odb.cfg

[zbxdb]
db_url = //x.x.x.x:1522/SKOLMMCP
username =
password =
db_type = oracle
db_driver = cx_Oracle
instance_type=rdbms
role = normal
out_dir = $HOME/zbxora_out
hostname = srvzrorgDB01-SKOLMMCP
checks_dir = $HOME/etc/zbxdb_checks
site_checks=primary.12
password_enc =

  1. python-3.6.5 zbxdb-2.07

  2. oracle 12c

  3. Linux proxy-test-final 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

  4. n/a

zbxdb log contains only this for all freezed processes, but similar times:

SERVER1
2020-08-07 15:34:04,023___main___20_connect 2 times, 0 fail; started 778180 queries, 0 fail memrss:28260 user:325.820750 sys:145.189229
2020-08-07 16:34:03,615___main___20_connect 2 times, 0 fail; started 778990 queries, 0 fail memrss:28260 user:326.171351 sys:145.336411
2020-08-07 17:34:03,862___main___20_connect 2 times, 0 fail; started 779794 queries, 0 fail memrss:28260 user:326.514880 sys:145.490424
2020-08-07 18:02:19,626___main___30_zbxdb cancel_sql checks_01m scn
2020-08-07 18:02:19,627___main___30_zbxdb canceled checks_01m scn

SERVER2
2020-08-07 16:27:31,140___main___20_connect 3 times, 0 fail; started 1298857 queries, 1 fail memrss:28184 user:567.861537 sys:257.641800
2020-08-07 17:27:31,232___main___20_connect 3 times, 0 fail; started 1299661 queries, 1 fail memrss:28184 user:568.213330 sys:257.804576
2020-08-07 18:06:44,144___main___30_zbxdb cancel_sql checks_05m u_ts
2020-08-07 18:06:44,145___main___30_zbxdb canceled checks_05m u_ts

SERVER 3
2020-08-07 16:27:29,233___main___20_connect 2 times, 0 fail; started 1298930 queries, 0 fail memrss:28216 user:565.671102 sys:260.828943
2020-08-07 17:27:29,597___main___20_connect 2 times, 0 fail; started 1299734 queries, 0 fail memrss:28216 user:566.019291 sys:260.980762
2020-08-07 18:00:06,591___main___30_zbxdb cancel_sql checks_01m sysstat
2020-08-07 18:00:06,592___main___30_zbxdb canceled checks_01m sysstat

SQL Error in etc/zbxdb_checks/oracle/primary.11.cfg

Describe the bug
SQL Error in etc/zbxdb_checks/oracle/primary.11.cfg

To Reproduce
Steps to reproduce the behavior:

  1. cfg file obfuscate entries like address, username and password
    etc/zbxdb_checks/oracle/primary.11.cfg
  2. driver version
  3. db version
    11.2.0.4
  4. monitoring platform
    Zabbix 4.4.7
  5. failing SQL
    rman.lld: select distinct(object_type) "{#OBJ_TYPE}" from v$rman_status where operation like 'BACKUP%'
    union all
    select 'usermanaged' from v$backup where change # > 0 and file# = 1

It is extra space in "change #"
The "change#" is right.

Simplify deployment with Docker and Docker Compose.

Python and its pyvenv
I'm always frustrated when I have to set up pyvenv or raw python instance in any kind of environment.

Solution
It seems to be a good idea to Dockerize the project using Python 3.6 base with ports exposed and volumes if needed.

If it's up to you, I would like to do that.

autodiscovery failed on Postgresql 11

error message:

key=checks_60m.p_ts ZBXDB-42501: Db execution error: permission denied for tablespace pg_global

i've created user with following permissions:

CREATE USER zabbix WITH ENCRYPTED PASSWORD 'password';
GRANT CONNECT ON DATABASE postgres TO zabbix;
GRANT USAGE ON SCHEMA public TO zabbix;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO zabbix;

if i call p_ts.lld query manually, it returns correct data.

can i login in oracle 10g dg with sysdba role?

hi,i try to login in oracle 10g dg with sysdba role.
here is my config file:

[zbxdb@dhec-vm-264 etc]$ cat zbxdb.odb_2_154.cfg
[zbxdb]
db_url = //172.16.2.154/dhecrac
username = zabbix
password =
db_type = oracle
db_driver = cx_Oracle
instance_type = rdbms
role = SYSDBA
out_dir = $HOME/zbxora_out
hostname = orclsig2154
checks_dir = etc/zbxdb_checks
site_checks =
password_enc = WnNjMjAxOVphYmJpeA==

it's not a right way,here is the error messages:

INFO:main:connecting to zabbix/******@//172.16.2.154/dhecrac

WARNING:main:(2.21)connection error: [1031] ORA-01031: insufficient privileges for zabbix@//172.16.2.154/dhecrac

i had try it in sqlplus:

C:\Users\oracle>sqlplus zabbix/******@172.16.2.154/dhecrac as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on 星期二 8月 6 18:12:37 2019

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

How can I analyze and resolve this issue?
Thank you, I look forward to your reply.

Problem with Oracle and TNS NAMES

Hi to all, I got this error:

2020-10-14 12:13:52,609___main___40_(1.1)connection error: [12514] ORA-12514: TNS:listener does not currently know of service requested in connect descriptor for zbxdb@//192.168.***.***:1521/db1

I've set this env variable:
TNS_ADMIN=/usr/lib/oracle/12.1/client64

This my etc/zbxdb.odb.cfg file:

[zbxdb]
db_url = //192.168.***.***:1521/db1
username = zbxdb
password =
db_type = oracle
db_driver = cx_Oracle
instance_type = rdbms
role = normal
out_dir = $HOME/zbxora_out
hostname = testhost
checks_dir = etc/zbxdb_checks
site_checks = sap,ebs
password_enc = emFiYml4

Inside $TNS_ADMIN there is tnsnames.ora file with these two entries:

db1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.***.***)(PORT = 1521))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = db1.***.com))
  )

db2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.***.***)(PORT = 1521))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = db2.***.com))
  )

Whats wrong in my configuration?
Thanks a lot
Stefano

Send data to Zabbix server but don't delivery

Describe the bug
I configure simple Oracle DB but nodata in Zabbix server. Data collect in zbxora_out/zbxdb.vs-tst00-idb01.zbx but don't delivery to Zabbix Server.

To Reproduce
Steps to reproduce the behavior:

  1. cfg file obfuscate entries like address, username and password
    cat zbxdb.vs-tst00-idb01.cfg
    [zbxdb]
    db_url = //vs-tst00-idb01/B2BSKTST
    username = cistats
    password =
    db_type = oracle
    db_driver = cx_Oracle
    instance_type = rdbms
    role = normal
    out_dir = $HOME/zbxora_out
    hostname = vs-tst00-idb01
    checks_dir = etc/zbxdb_checks
    site_checks = primary.11
    password_enc = *******

  2. driver version
    Oracle Instant Client 19.3

  3. db version
    11.2.0.4

  4. monitoring platform
    Zabbix Server 4.4.7

  5. failing SQL
    No SQL

Expected behavior

logs


cat ../log/zbxdb_starter.log
Tue Jun 16 15:18:01 MSK 2020 Starting etc/zbxdb.vs-tst00-idb01.cfg


cat ../log/zbxdb.vs-tst00-idb01.cfg.log
2020-06-16 15:18:01,864___main___30_start python-3.6.5 zbxdb-2.07 pid=126139 Connecting ...

2020-06-16 15:18:01,865___main___30_zbxdb found db_type=oracle, driver cx_Oracle; checking for driver

2020-06-16 15:18:04,936___main___50_file etc/zbxdb_checks/oracle/primary.11.cfg has parsing errors ->(13)

2020-06-16 15:18:04,941___main___50_file etc/zbxdb_checks/oracle/primary.11.cfg has parsing errors ->(13)


crontab -l

          • $HOME/zbxdb/bin/zbxdb_starter > /dev/null 2 >&1
          • $HOME/zbxdb/bin/zbxdb_sender.py -c /etc/zabbix/zabbix_agentd.conf -z zbxdb_out > /dev/null 2 >&1

monitoring platform:
CentOS Linux release 7.7.1908 (Core)
python 3.6.5

Additional context

Template localization

Some descriptions in template are not in English, could you please provide us an English verion, thank you! 😄

Reduce ambiguity around Application name grouping

Is your feature request related to a problem? Please describe.

Zabbix has no hierarchy of Applications, so the current Application names in the template are spread across the alphabetic spectrum. There's also some ambiguity and potential clashes with some Application names, especially with some of our self-service dashboard users accessing these data from Graphana.

Application names in the v4_EN template include:

ACFS, ASM, ASMVG, backup, db, inst, inst.parm, inst.perf, locks, log, objects, performance, sql, tsmaxsize, tspctfree, tssize, tsused, ttsmaxsize, ttspctfree, ttssize, ttsused, undoTS, users, zbxdb

Describe the solution you'd like

Prefix each Application with a unique string - eg. db_ - so that the Applications are grouped together (as they're usually shown alphabetically), and remove ambiguity (eg. db_users is more obvious than just 'users')

Possibly consider scenarios where we have two database engines on the same host (it's not common, but I've seen MySQL and PostgreSQL on the same host) - which in the current, and even my proposed change, will break in weird ways. I have no idea how to elegantly handle that situation.

Describe alternatives you've considered

I can modify the template myself, but this will break on future updates to that file.

Also, the XML wrangling isn't something that's easy to automate.

the zbxdb_sender shell script in bin is missing

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. cfg file obfuscate entries like address, username and password
  2. driver version
  3. db version
  4. monitoring platform
  5. failing SQL

Expected behavior
A clear and concise description of what you expected to happen.

logs
If applicable, add logs to help explain your problem.

monitoring platform:

  • distribution, version
  • python version
  • driver version

Additional context
Add any other context about the problem here.

zbxdb collecting data but not inserting into Zabbix

My zbxdb installation is collecting data as I have seen the archive files. However, I am not seeing any data in my Zabbix portal. My cfg file is as follows:
[zbxdb]
db_url = //localhost/zabbix
username = zabbix_stat
password =
db_type = mssql
server = 10.10.16.12
server_port = 1433
db_name = master
db_driver = pytds
role = normal
out_dir = $ZBXDB_HOME/zbxdb_out
hostname = vserver15768
checks_dir = etc/zbxdb_checks
site_checks = NONE

cafile = $HOME/somecapemfile

instance_type = rdbms

The hostname and IP address are of my mssql database server. My Zabbix repository is on the localhost and obviously Mysql. I created a host for the hostname above and linked to the template provided. Why would I not see any data in Zabbix? Thank you

Trouble with using zbxdb_sender

Hello, couldn't start zbxdb_sender.py, i get this error message:

Falling back to default logging config
Traceback (most recent call last):
File "zbxdb_sender.py", line 59, in
LOGGER.warning("Logging in %s", LOGGER.root.handlers[1].baseFilename)
IndexError: list index out of range

Connect to Azure MSSQL - how to enable encryption?

I am trying to connect o Azure MSSQL 12 DB

When I run command
python3 /home/zbxdb/bin/zbxdb.py -c $HOME/etc/zbxdb.mssql_prod.cfg

I am getting an error

CRITICAL:main:problem
Traceback (most recent call last):
File "/home/zbxdb/bin/zbxdb.py", line 395, in main
_conn = db_connections.connect(db_driver, _config)
File "/home/zbxdb/bin/dbconnections/mssql.py", line 63, in connect
appname=_c['ME']
File "/usr/local/lib/python3.6/site-packages/pytds/init.py", line 1196, in connect
conn._open()
File "/usr/local/lib/python3.6/site-packages/pytds/init.py", line 349, in _open
raise last_error
File "/usr/local/lib/python3.6/site-packages/pytds/init.py", line 302, in _open
conn.login(login, sock, self._tzinfo_factory)
File "/usr/local/lib/python3.6/site-packages/pytds/tds.py", line 1712, in login
self._main_session.process_prelogin(login)
File "/usr/local/lib/python3.6/site-packages/pytds/tds.py", line 1363, in process_prelogin
raise tds_base.Error('Client does not have encryption enabled but it is required by server, '
pytds.tds_base.Error: Client does not have encryption enabled but it is required by server, enable encryption and try connecting again

Configuration

[zbxdb]
db_url=//DBSERVER.database.windows.net/database
username = USERNAME
password =
db_type=mssql
server=DBSERVER.database.windows.net
server_port=1433
db_name=master
db_driver=pytds
role=normal
out_dir=$HOME/zbxdb_out
hostname=mssql_prod
checks_dir=etc/zbxdb_checks
site_checks=NONE
instance_type=rdbms
password_enc=

Server
Linux Oracle
4.14.35-1902.7.3.el7uek.x86_64 #2 SMP Thu Oct 31 10:06:41 PDT 2019 x86_64 x86_64 x86_64 GNU/Linux

monitoring platform:

  • distribution, version - latest version of zbxdb
  • python version - python 3.6
  • driver version

Thank you for help

Cant apply v4 template on host

Hello,
Zabbix 4.0.7
When I try to apply template v4 on windows host I get errors.

I tried to recreate that host. And I get same error.

 Details Cannot update host

    Error in query [INSERT INTO applications (name,hostid,applicationid) VALUES ('ACFS','10354','2438'),('ASM','10354','2439'),('ASMVG','10354','2440'),('backup','10354','2441'),('db','10354','2442'),('inst','10354','2443'),('inst.parm','10354','2444'),('inst.perf','10354','2445'),('locks','10354','2446'),('log','10354','2447'),('objects','10354','2448'),('performance','10354','2449'),('sql','10354','2450'),('tsmaxsize','10354','2451'),('tspctfree','10354','2452'),('tssize','10354','2453'),('tsused','10354','2454'),('ttsmaxsize','10354','2455'),('ttspctfree','10354','2456'),('ttssize','10354','2457'),('ttsused','10354','2458'),('undoTS','10354','2459'),('users','10354','2460'),('zbxdb','10354','2461')] [Duplicate entry '10354-performance' for key 'applications_2']
    SQL statement execution has failed "INSERT INTO applications (name,hostid,applicationid) VALUES ('ACFS','10354','2438'),('ASM','10354','2439'),('ASMVG','10354','2440'),('backup','10354','2441'),('db','10354','2442'),('inst','10354','2443'),('inst.parm','10354','2444'),('inst.perf','10354','2445'),('locks','10354','2446'),('log','10354','2447'),('objects','10354','2448'),('performance','10354','2449'),('sql','10354','2450'),('tsmaxsize','10354','2451'),('tspctfree','10354','2452'),('tssize','10354','2453'),('tsused','10354','2454'),('ttsmaxsize','10354','2455'),('ttspctfree','10354','2456'),('ttssize','10354','2457'),('ttsused','10354','2458'),('undoTS','10354','2459'),('users','10354','2460'),('zbxdb','10354','2461')".

I dont know much about zabbix templates, v3 template imported and applied without problems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.