vagabondan / DBforBIX

DBforBix since 3.0 version is managed from Zabbix Web interface and behaves like an ordinary active Zabbix Proxy. Current version: DBforBIX 3.2.0
GNU General Public License v3.0
8 stars 1 forks source link

Does not execute query #4

Closed smartmarmot closed 7 years ago

smartmarmot commented 7 years ago

Hi Vagabondan I'm finally running the project with your updates. All I see is that DBforBIX is looping refreshing the configuration. Can you explain to me how does it works? I see no data sent and no query executed nor a connection to the db. Also as far I can see is not evven asking the server to provide the host list

smartmarmot commented 7 years ago

I see is all in the config class

smartmarmot commented 7 years ago

It arrives here looking for DB4bix.config, that is empty maybe there are some issues with the templates:

for(int it=0;it<items.get("key_").size();++it){
                String key=items.get("key_").get(it);
                if(key.contains(zs.getZabbixItemConfigSuffix())){
                    String hostid=items.get("hostid").get(it);
                    if(hostFilter.contains(hostid)) 
                        continue;
                    String host=zs.getHostByHostId(hostid);                     
smartmarmot commented 7 years ago

I've found a small issue, the suffix is not set in the template file. I spent a few time to find the issue :)

vagabondan commented 7 years ago

Hi Andrea! Sorry for delay. DBforBix is refreshing configuration with configurable period of time. Configuration consists now from 2 different pieces:

  1. Local file config is used to store some basic properties, monitored DB connection related data with login and passwords (its more secure to store them local than in web interface of Zabbix Servers) and names of Zabbix Proxies which are used by DBforBix while contacting with Zabbix Servers.
  2. Configurations defined in Zabbix Server web interface: each item with suffix *.DB4bix.config is considered as DBforBix configuration. Such items have to be defined on hosts belongs to Zabbix Proxy corresponding to DBforBix. DBforBix uses Zabbix Proxy name to identify itself as corresponding Zabbix Proxy and get all related entities that belong to it: hosts, host macros, items, templates and so on.

DBforBix refreshes both configurations periodically. It calculates md5 hash sums for local file config and each configuration in Zabbix Server Web interface separately:

  1. If new hash differs from previous for local file config then DBforBix fully reinitialize itself.
  2. If new hash differs from previous for one or several Zabbix Web Server configs, then DBforBix only updates its items for such configs.
vagabondan commented 7 years ago

As far as I see, template for Oracle includes DB4bix.config: https://github.com/vagabondan/DBforBIX/blob/master/template/zbx_proxy_templates_oracle.xml#L318

So does MySQL template: https://github.com/vagabondan/DBforBIX/blob/master/template/zbx_proxy_templates_mysql.xml#L5283

What template file have you used?

smartmarmot commented 7 years ago

Hi Andrey, don't worry there is no rush :) I've used your oracle template and indeed dvbforbix retrieve all tha data from Zabbix server. Unfortunately (I am still debugging why) it does not run any query, I think ill be able to sort it out on the next days.

vagabondan commented 7 years ago

Have you defined correct {$DSN} macro on your host?

smartmarmot commented 7 years ago

I haven't defined any variable. can you provide me an example?

smartmarmot commented 7 years ago

sorry I mean macro

vagabondan commented 7 years ago

Sure, as you can see there is the {$DSN} macro in web configuration items: https://github.com/vagabondan/DBforBIX/blob/master/template/zbx_proxy_templates_oracle.xml#L318

I've inserted all config ietms in discovery item. Small instruction:

  1. Let's create new host representing individual DB that we will monitor.
  2. Apply DBforBix template on it.
  3. Define DSN macro name inside that host. This name should be exactly the same as one defined in DBforBix local file config: DB. and included in DBList for Zabbix Server you are working on.

User macros (i.e. {$}) are parsed by DBforBix when it gets Zabbix Web Configurations and substituted by real names. You should define {$DSN} macro according to DB name in each host you are applying the template on. DSN stands for Data Source Name and came from ODBC configurations (Zabbix native DB monitoring approach).

vagabondan commented 7 years ago

Also, some explanation is placed on DBforBix wiki page, see "Configuration milestones": https://github.com/vagabondan/DBforBIX/wiki

smartmarmot commented 7 years ago

Ahhhhh I see!!!! This is the connection!

vagabondan commented 7 years ago

image

smartmarmot commented 7 years ago

Большое спасибо за ваши объяснения!!!

vagabondan commented 7 years ago

Пожалуйста! Всегда рад помочь!:)

vagabondan commented 7 years ago

Finally, screen from local file config: image

vagabondan commented 7 years ago

DB should be defined as second parameter in config item by analogy with native zabbix Database monitor agent type: image

vagabondan commented 7 years ago

I believe, the issue can be closed.