English 中文(简体)
Zabbix - Macro {$MYSQL.DSN} without odbc.ini entry
原标题:
  • 时间:2023-09-03 23:10:08
  •  标签:
  • zabbix

Is there a way to configure {$MYSQL.DSN} without odbc.ini entry? Not necessary need to be using {$MYSQL.DSN}, but where can I only use connection string without odbc.ini in host configuration page from zabbix?

Something like {$MYSQL.DSN} = db.odbc.select[,"DRIVER={MariaDB};SERVER=192.168.0.112;DATABASE=teste;USER=danilo;PASSWORD=test123;OPTION=3;"]

问题回答

Yes, it is possible since version 5.0 of Zabbix: https://www.zabbix.com/documentation/5.0/en/manual/introduction/whatsnew500#odbc-monitoring-without-dsn

An example of what a connection string would look like in the item key in Zabbix (always try to use user macros to configure values such as the database name, MySQL server address, username and password):

db.odbc.get[your_sql_query,,"Driver=/usr/local/lib/libmyodbc8w.so;Database={$MYSQL.DATABASE};Server={$MYSQL.SERVER};Port={$MYSQL.PORT}"]

It seems that the official Zabbix documentation doesn t provide a very clear example of how to do this, but if you search on this page for "db.odbc.get" you will find an example.

MySQL documentation on how to install the ODBC connector.

Below is an example of how the ODBC driver can be installed in the official zabbix-server Docker image (in this example, Zabbix was running on an Ubuntu 22.04 64-bit ARM architecture):

  1. Download the ODBC driver: https://dev.mysql.com/downloads/connector/odbc/
  2. Extract the archive:
tar zxvf mysql-connector-odbc-8.1.0-linux-glibc2.28-aarch64.tar.gz
  1. The extra directory contains two subdirectories, lib and bin. Copy their contents to the proper locations on your system:
cp bin/* /usr/local/bin
cp lib/* /usr/local/lib
  1. Register the driver:
myodbc-installer -a -d -n "MySQL ODBC 8.1 Unicode Driver" -t "Driver=/usr/local/lib/libmyodbc8w.so"
  1. Verify that the driver is installed and registered using the ODBC manager, or the myodbc-installer utility:
myodbc-installer -d -l

And of course, don t forget that when configuring your Zabbix Server (or Zabbix Proxy) you need to have at least 1 instance of the ODBC poller (StartODBCPollers parameter)





相关问题
Zabbix - Macro {$MYSQL.DSN} without odbc.ini entry

Is there a way to configure {$MYSQL.DSN} without odbc.ini entry? Not necessary need to be using {$MYSQL.DSN}, but where can I only use connection string without odbc.ini in host configuration page ...

How to expose data to zabbix

Here is my goal: I would like to be able to report various metrics to zabbix so that we can display the graphs on a web page. These metrics include: latency per soap service submission various ...

Does Nagios have an API that can control targets?

In Zabbix, there is a well documented (although in Draft status) API for instantiating targets and controlling them. Does such an API exist in Nagios? The need for this is a cloud-based ...

active directory monitoring

I want to develop a monitoring tool to monitor active directory like (solar wind,op manager etc). For this purpose,I have chosen Zabbix(an open source tool) to monitor AD and provide me real time ...

热门标签