New DBforBIX as Zabbix Proxy

SmartMarmot edited this page May 26, 2017 · 9 revisions

Welcome to DBforBix wiki!

NOTE: Since the version 2.4 DBforBIX act as a Zabbix Proxy, so it is incompatible with the old DBforBIX 2.2. You can find all the previous version here .
DBforBix is the DB monitoring tool for Zabbix. It works like an active Zabbix Proxy by getting configuration from Zabbix Server and sending the results back.

Key features/aims of DBforBix

  1. Closest integration with Zabbix Web interface. You can control DB monitoring with DBforBix just like it were ordinary Zabbix Proxy.
  2. As a consequence of p.1, DBforBix updates its configuration and behaviour on the fly.
  3. DBforBix supports Low Level Discovery.
  4. DBforBix supports multirow and multicolumn selects from databases. This feature greatly improves effeciency of DB monitoring.
  5. DBforBix understands and resolves Host/Templates macros (i.e. {$DSN}, {$ANY_OTHER_STUFF}, etc.)
  6. DBforBix checks hosts statuses and stop monitoring for disabled hosts and start for enabled.
  7. DBforBix process nodata events by returning default configurable values.
  8. DBforBix is able to monitor as many different DB types as JDBC technology can, but tested only on MySQL and Oracle DBs for now.
  9. One instance of DBforBix can handle several different Zabbix Servers with different hosts/items configurations at a time, i.e. it can be a Zabbix Proxy for multiple Zabbix Servers.

Known drawbacks

  1. Not all useful fields in Zabbix items Web Interface are used, e.g. "Update interval".
  2. Main configuration is situated in "SQL query field" of "Database monitor" item type in XML format which is not very convenient for humans.
  3. Symbols ">" and "<" in SQL queries should be converted to HTML equivalents &gt; and &lt;.

Configuration milestones

  1. Create new Proxy in Zabbix Web interface for DBforBix, e.g. name it DBforBix.

  2. Choose server and location on filesystem (BASE DIRECTORY) where dbforbix_run_XXX.jar has to be placed.

  3. Copy DBforBIX dist to $BASEDIR

  4. Edit configuration files $BASEDIR/ and $BASEDIR/conf/
    4.1 $BASEDIR/ controls log4j logger subsystem
    4.2 In $BASEDIR/conf/ you have to define:
    4.2.1 Zabbix server host (ZabbixServer.Zabbix1.Address). Zabbix1 here is formal name of Zabbix Server instance. You may choose any other identifier you want, but keep it the same through the Zabbix Server options definition. Also you can create several Zabbix Servers (e.g. Zabbix2, Zabbix3, etc.) definitions. DBforBix will try to handle (became their Zabbix Proxy) them all.
    4.2.2 Zabbix Server trapper port (ZabbixServer.Zabbix1.Port, 10051 by default)
    4.2.3 Zabbix Proxy name, in accordance with p.1 - DBforBix (ZabbixServer.Zabbix1.ProxyName). It should be the same as you created in Zabbix Web Interface.
    4.2.4 List of predefined DB names, which you will describe later in this file and declare in Zabbix Web Interface as value of host/template macro {$DSN} (ZabbixServer.Zabbix1.DBList=MYSQLDB1,ORADB1). Here we name DBs MYSQLDB1 and ORADB1 for example. You can choose any other name you want. You may create any longer list of databases.
    4.2.5 Define each database that you have included in DB list above: see examples for MySQL, Oracle DBs

  5. Import templates for MySQL and/or Oracle DB types to your Zabbix Server through Zabbix Web interface

  6. Create hosts in Zabbix Web interface each representing DBs that you want to monitor and apply templates imported in previous paragraph in accordance with their database types (MySQL, or Oracle). You can name hosts whatever you want. They are not important for identifying DBs. Important is to define that theese hosts have to be monitored via Zabbix Proxy DBforBix.

  7. Define macro {$DSN} in each created host. The macro value should be one from the DBList (ZabbixServer.Zabbix1.DBList=MYSQLDB1,ORADB1) defined earlier in local configuration file for this Zabbix instance.

  8. That's all. Run DBforBix from $BASEDIR with the following command:

    java -jar dbforbix_run_2.3-beta.jar -b `pwd` -a start

Some explanation

After start DBforBix finds file in $BASEDIR/conf directory and read it. Then it connects to defined Zabbix Server as Zabbix Proxy and find enabled hosts with item keys ending with .*DBforBIX.config (dot and star here represent any symbols). You can specify any other config suffix in local DBforBix config as you wish. This key have to have 2 parameters:
<someid> - some your identifier (whatever you want),
{$DSN} - macro (or direct DB name), which should be defined in host macros and it value should be present in local configuration file in DBList (ZabbixServer.Zabbix1.DBList=MYSQLDB1,ORADB1).

Items with keys .*DBforBIX.config should be of type Database monitor and should contain DBforBix-like XML configuration in SQL query field, e.g.:
Below is an example of usual Zabbix item which should have key mysql.version.DBforBIX.config and type dbmonitor. Since it has DBforBIX.config suffix, it is the DBforBix config item at the same time.
<parms type="mysql" prefix="mysql.">
<query time="600" item="version.DBforBIX.config">SHOW VARIABLES LIKE "version"</query>
Below is an example of Zabbix discovery item that should have item key oracle.discovery.DBforBIX.config[instanceid,{$DSN}]. Since it has DBforBIX.config suffix, it is the DBforBix config item at the same time.
<parms type="oracle" prefix="oracle.">
<discovery time="120" item="discovery.DBforBIX.config[instanceid,{$DSN}]" names="INST_ID">select inst_id from gv$instance</discovery>
<query time="60" item="stats[%1,%2]">SELECT inst_id, REPLACE(name,' ','_'), value FROM gv$sysstat WHERE name IN ('user I/O wait time','physical read total bytes','physical write total bytes','lob reads','lob writes','db block changes','db block gets','consistent gets','physical reads')</query>
See imported Zabbix templates for details.

You can place in SQL field of DBforBix config item full XML config with root element - parms. You can make it so complex as you wish. DBforBix creates separate thread to serve every single config item to avoid mutual influence of different config items. But do not forget to create items - receivers of data. For config item above you should create item prototypes with keys: oracle.stats[{#INST_ID},user_I/O_wait_time] oracle.stats[{#INST_ID},physical_read_total_bytes] ... oracle.stats[{#INST_ID},physical_write_requests_optimized]

For more information, please see Zabbix templates for DBforBix.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.