Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-10162

Add Connection String Support to MSSQL ODBC Template

XMLWordPrintable

    • Icon: Change Request Change Request
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • 7.0.16
    • Templates (T)

      Currently, the out-of-the-box Zabbix template for Microsoft SQL Server via ODBC only supports connections using DSNs (configured in /etc/odbc.ini). There is no option in the template to define a full ODBC connection string, which limits usability and flexibility—especially in environments where maintaining DSNs across proxies or agents is impractical.

      Use Case:

      Zabbix already supports two approaches when using custom db.odbc.get[] items:

      1. Using DSN:
        db.odbc.get["MS SQL ODBC test", "MSSQLDSN", ""]
      2. Using Connection String:
         
        db.odbc.get["MS SQL ODBC test", "", "Driver=MSSQL;Server=10.20.10.20,2222;TrustServerCertificate=yes;UID=zabbix_monitor;PWD=zabbix_monitor_pwd"]
        Or with credentials in separate macros:
        db.odbc.get["MS SQL ODBC test", "", "Driver=MSSQL;Server=10.20.10.20,2222;TrustServerCertificate=yes;"]

      However, the official MSSQL template only supports macro-based DSN configuration like this:

      Macro Description
      {$MSSQL.DSN} System DSN
      {$MSSQL.HOST} SQL Server host
      {$MSSQL.PORT} TCP port
      {$MSSQL.USER} Username
      {$MSSQL.PASSWORD} Password

       
      There is no macro to define a connection string.

       

      Comparison with Other Templates:

      The PostgreSQL and Oracle templates already support full connection strings via macros such as {}{$PG.CONNSTRING.ODBC}{}.

      Example:
      {$PG.CONNSTRING.ODBC} = Servername=127.0.0.1;Port=5432;Driver=/usr/lib64/psqlodbcw.so;Database=postgres;Username=zbx_monitor;Password=zabbix_monitor_pwd
      This makes these templates more portable and easier to configure in dynamic environments.

      Suggestion:

      Please add support for a new macro (e.g. {}{$MSSQL.CONNSTRING.ODBC}{}) in the official Microsoft SQL Server by ODBC template, which would allow full ODBC connection strings to be used directly in the UI without relying on /etc/odbc.ini.

      Proposed behavior:

      • If {$MSSQL.CONNSTRING.ODBC} is defined, use it as the third argument in db.odbc.get[]
      • Fallback to using {$MSSQL.DSN} if no connection string is provided
      • Update documentation and macros accordingly

      Benefits:

      • Simplifies MSSQL monitoring setup across multiple proxies/agents
      • Avoids the need for root access to edit /etc/odbc.ini
      • Aligns MSSQL support with PostgreSQL and Oracle templates
      • Increases adoption of ODBC features in Zabbix

      Test Case (Linux):

       
      # Without DSN:
      isql -v -k "Driver=/usr/lib64/libmsodbcsql-18.so;Server=10.20.10.20,2222;UID=zabbix_monitor;PWD=zabbix_monitor_pwd;TrustServerCertificate=yes"
       
      # With partial DSN override:
      isql -v -k  "DSN=MSSQLDSN;Server=10.20.10.20,2222;UID=zabbix_monitor;PWD=zabbix_monitor_pwd;"
       

            vjaceslavs Vjaceslavs Bogdanovs
            zekonja Krunoslav Hrnjak
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: