Is it possible to pass multiple commands in userparamters?
UserParameter=item,port=`netstat -plntu 2>/dev/null | grep process_name | awk '{print $4}' | awk -F":" '{print $2}'`; echo $port;
or
UserParameter=item,bash -c "port=`netstat -plntu 2>/dev/null | grep process_name | awk '{print $4}' | awk -F":" '{print $2}'`; echo $port;"
or
UserParameter=item,bash -c "port=`netstat -plntu 2>/dev/null | grep process_name | awk '{print $4}' | awk -F":" '{print $2}'` && echo $port;"
None of these echo the port number. It returns empty.
Similar question with no answer - https://www.zabbix.com/forum/zabbix-...-part-commands
UserParameter=item,port=`netstat -plntu 2>/dev/null | grep process_name | awk '{print $4}' | awk -F":" '{print $2}'`; echo $port;
or
UserParameter=item,bash -c "port=`netstat -plntu 2>/dev/null | grep process_name | awk '{print $4}' | awk -F":" '{print $2}'`; echo $port;"
or
UserParameter=item,bash -c "port=`netstat -plntu 2>/dev/null | grep process_name | awk '{print $4}' | awk -F":" '{print $2}'` && echo $port;"
None of these echo the port number. It returns empty.
Similar question with no answer - https://www.zabbix.com/forum/zabbix-...-part-commands
Comment