Does anyone know how to pass a parameter to awk print column command which is defined in zabbix agent UserParameter?
I have a key
swapinfo[memory,5]
And corresponding UserParameter in zabbix_agentd.conf file
UserParameter=swapinfo[*],swapinfo -t | grep $1 | awk -F' ' '{print $2}'
... so I need this to execute
swapinfo -t | grep memory | awk -F' ' '{print $5}'
But it's either executing awk -F' ' '{print $2}' or returnes ZBX_NOTSUPPORTED
I also tried to use $$2 and \$$2 and \$\$2.
And no, I don't want to use wrapper script, because I have to use this feature on many servers. And maintaining those scripts means extra work.
Do you think this can be done?
I have a key
swapinfo[memory,5]
And corresponding UserParameter in zabbix_agentd.conf file
UserParameter=swapinfo[*],swapinfo -t | grep $1 | awk -F' ' '{print $2}'
... so I need this to execute
swapinfo -t | grep memory | awk -F' ' '{print $5}'
But it's either executing awk -F' ' '{print $2}' or returnes ZBX_NOTSUPPORTED
I also tried to use $$2 and \$$2 and \$\$2.
Code:
bash-4.0# swapinfo -t
Kb Kb Kb PCT START/ Kb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 8388608 10676 8377932 0% 0 - 1 /dev/vg00/lvol2
dev 8388608 10556 8378052 0% 0 - 1 /dev/vg00/swap2
reserve - 16587652 -16587652
memory 23805996 5099444 18706552 21%
total 40583212 21708328 18874884 53% - 0 -
Do you think this can be done?

Comment