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

Not possible to use awk with $-sign in UserParameter in agent2

XMLWordPrintable

    • Sprint 71 (Dec 2020), Sprint 72 (Jan 2021)
    • 1

      Steps to reproduce:

      1. Use a UserParameter as follows:
        UserParameter=a.b.c[*],psql -h $1 -U $2 -d $2 -c 'SELECT count(*) FROM x.y WHERE "Type" IN ($4)' -x | grep count | awk '{print $$3}'
      2. In this way awk used to filter out only the resulting number of the sql-count.
      3. As you can see, I used a double $$ to 'escape' the awk variable, as this variable number overlaps with the number of variables sent to the UserParameter
      4. This worked fine in the old agent, but not anymore in agent2

       

      Result:
      The result when using

      awk '{print $$3}'

      is that awk isn't invoked and I get the complete row, as filtered by grep: "count | 123".

      The result when using

      awk '{print \$3}'

      is that I get the actual password sent to the UserParameter, which is the $3-parameter.

      Expected:
      I'd expect similar behaviour of agent2 when working with external variables in UserParameters.

      If the way of escaping has changed, I expect to see a notification of this change + the proper way of escaping in the documentation.

            viktors.tjarve Viktors Tjarve
            Erwin Erwin Bogaard
            Team A
            Votes:
            8 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved: