Hi,
I'm trying to iterate over a list with ip addresses in conjunction with zabbix_sender like so:
#!/bin/bash
cat list.txt | while read card
do
echo $card
rx1=$(invoke -a $card 3302448@0000:00:00? | awk '{ print $7}' |tail -n +2)
zabbix_sender -z 10.160.0.121 -s $card -k receive.power1 -o $rx1
rx2=$(invoke -a $card 3302448@0000:00:00? | awk '{ print $7}' |tail -n +2)
zabbix_sender -z 10.160.0.121 -s 172.16.1.116 -k receive.power1 -o $rx1
done
The list.txt just consists of:
172.16.1.116
172.16.1.117
172.16.1.118
172.16.1.119
etc.
Upon executing the script, the response is as follows:
172.16.1.116 (comes from echo $card line in script)
info from server: "processed: 0; failed: 1; total: 1; seconds spent: 0.000022" sent: 1; skipped: 0; total: 1
info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000065" sent: 1; skipped: 0; total: 1
So zabbix_sender with variable $card fails and zabbix_sender with plain IP address works.
Could someone enlighten me on how to encapsulate this variable properly if bare $card variable is not working?
I've tried $("card"), ${"card"}, ($card), "($card)"
The manual does not describe in any way shape or form the use of variables in zabbix_sender, oddly enough the -o $rx1 as variable works like a charm and is correctly called as such.
I'm trying to iterate over a list with ip addresses in conjunction with zabbix_sender like so:
#!/bin/bash
cat list.txt | while read card
do
echo $card
rx1=$(invoke -a $card 3302448@0000:00:00? | awk '{ print $7}' |tail -n +2)
zabbix_sender -z 10.160.0.121 -s $card -k receive.power1 -o $rx1
rx2=$(invoke -a $card 3302448@0000:00:00? | awk '{ print $7}' |tail -n +2)
zabbix_sender -z 10.160.0.121 -s 172.16.1.116 -k receive.power1 -o $rx1
done
The list.txt just consists of:
172.16.1.116
172.16.1.117
172.16.1.118
172.16.1.119
etc.
Upon executing the script, the response is as follows:
172.16.1.116 (comes from echo $card line in script)
info from server: "processed: 0; failed: 1; total: 1; seconds spent: 0.000022" sent: 1; skipped: 0; total: 1
info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000065" sent: 1; skipped: 0; total: 1
So zabbix_sender with variable $card fails and zabbix_sender with plain IP address works.
Could someone enlighten me on how to encapsulate this variable properly if bare $card variable is not working?
I've tried $("card"), ${"card"}, ($card), "($card)"
The manual does not describe in any way shape or form the use of variables in zabbix_sender, oddly enough the -o $rx1 as variable works like a charm and is correctly called as such.
Comment