-
Documentation task
-
Resolution: Fixed
-
Trivial
-
None
-
Linux hosts
-
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:
- this will print the variable $FIRST
echo "$FIRST" - this will print $FIRST
echo '$FIRST'
So this is logic. But when i use flexible userparameter in zabbix it's a little bit other..:
- 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):
{print \$$5}" /mypath/myfile
UserParameter=info[*],awk "/$1/
# this works to ($1 is between single quotes ('') and zabbix agent is interpreting it):
UserParameter=info[*],awk '/$1/{print $$5}' /mypath/myfile
- 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