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

documentation userparameter

XMLWordPrintable

    • Sprint 27

      Hi,

      it's about the documentation on this site: https://www.zabbix.com/documentation/2.4/manual/config/items/userparameters

      I am using flexible userparameter. In bash, when you use duble quotes ("") then the dollar ($) signe is interpreted, but when you use single quotes ('') not.. I will work with examples, that's easyer:

      /bin/sh:

      1. this will print the variable $FIRST
        echo "$FIRST"
      2. this will print $FIRST
        echo '$FIRST'

      So this is logic. But when i use flexible userparameter in zabbix it's a little bit other..:

      1. this don't work:
        UserParameter=info[*],awk "/$1/ {print $5}" /mypath/myfile
        # this don't work but it will be logic ( take duble dollar: https://www.zabbix.com/documentation/2.4/manual/config/items/userparameters):
        UserParameter=info[*],awk "/$1/{print $$5}" /mypath/myfile
        # this works (i think sh gets 'awk "/$1/{print $5}

        " /mypath/myfile' from zabbix_agent):
        UserParameter=info[*],awk "/$1/

        {print \$$5}" /mypath/myfile
        # this works to ($1 is between single quotes ('') and zabbix agent is interpreting it):
        UserParameter=info[*],awk '/$1/{print $$5}

        ' /mypath/myfile

      2. this don't work:
        UserParameter=info[*],awk '/$1/ {print $5}' /mypath/myfile

        If I'm right this is happening:
        if the requested itemkey is: info[world]
        zabbix_agent interpret: awk "/$1/{print \$$5}" --> awk "/world/{print $5}

        " --> /bin/sh
        /bin/sh execute it like it's doing every time. So Zabbix_agent always replace $n with the parameter given in the itemkey (if it's between '' or not). Only when $$ is written then it only removes one $ and give the command to sh.

      I didn't know this befor and in the documentation it's not very clear. So i ask for improving the documentation at this place. I'll be very happy, and I think others to.

      Salutations
      Tuor

            martins-v Martins Valkovskis
            tuor tuor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: