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

    Details

    • Team:
      Team A
    • Sprint:
      Sprint 71 (Dec 2020), Sprint 72 (Jan 2021)
    • Story Points:
      1

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: