Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-7135

Unable to use macro values in "Database Monitor" item created through automatic discovery

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.1.3
    • 2.0.9
    • Server (S)
    • None
    • Debian 7.1 Wheezy

      We have a number of database monitor items that are created through Discovery Rules. The Discovery rule has a macro value "

      {#DBNAME}", which we can use in discovered item's parameters. If we try to use a generic macro value, the item becomes unsupported.

      Example item prototype parameters:

      case 1: (macro value specified on hostname)

      DSN={$DSN}
      sql=select numbackends from pg_stat_database where datname = '{#DBNAME}

      '

      -> fails

      case 2: (generic macro value)

      DSN=

      {HOSTNAME}
      sql=select numbackends from pg_stat_database where datname = '{#DBNAME}'

      -> fails

      case 3: (only use discovery macro value)

      DSN={#DBNAME}
      sql=select numbackends from pg_stat_database where datname = '{#DBNAME}'

      -> works

      log output:

      9170:20131010:150649.247 In substitute_key_macros() data:'db.odbc.select.database_size[{#DBNAME}]'
      9170:20131010:150649.247 In substitute_discovery_macros() data:'{#DBNAME}'
      9170:20131010:150649.247 End of substitute_discovery_macros() data:'zabbix'
      9170:20131010:150649.247 End of substitute_key_macros():SUCCEED data:'db.odbc.select.database_size[zabbix]'
      9170:20131010:150649.247 In substitute_discovery_macros() data:'Database size for {#DBNAME}'
      9170:20131010:150649.247 End of substitute_discovery_macros() data:'Database size for zabbix'
      9170:20131010:150649.247 In substitute_discovery_macros() data:'DSN={HOSTNAME}

      ^M
      sql=select pg_database_size('

      {#DBNAME}

      ')'
      9170:20131010:150649.247 End of substitute_discovery_macros() data:'DSN=

      {HOSTNAME}^M
      sql=select pg_database_size('zabbix')'
      9170:20131010:150649.247 In substitute_key_macros() data:''
      9170:20131010:150649.247 End of substitute_key_macros():FAIL data:''
      9170:20131010:150649.250 query [txnlev:1] [begin;]
      9170:20131010:150649.251 query [txnlev:1] [update items set params='DSN={HOSTNAME}

      sql=select pg_database_size(''zabbix'')' where itemid=24003;
      ]

      Similar issue in ZBX-4638 was solved (difference with this ticket is the use of discovery).

            Unassigned Unassigned
            rdesmet Ruben de Smet
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: