I try to add a discovery rule by external check for cisco switch to make dynamicaly creating items.
my script is
i get output like this
I allways get error "Value should be a JSON object". But it is valid - checked on https://jsonlint.com/ .
zabbix_server_log in debug mode says
In lld_rows_get()
End of lld_rows_get():FAIL
and nothing else.
Where am i wrong ?
p.s. zabbix server v 2.4.1
my script is
Code:
#!/bin/bash
. FILIAL_IP_LIST
printf "{\n"
printf '\t"data":['
first=true
cisco_ip=$1
filial_mask=$(echo $cisco_ip | cut -d '.' -f3)
for i in $filial_list
do
if [[ $(echo $i | cut -d '.' -f3) -eq "$filial_mask" || ( $filial_mask -eq "19" && $(echo $i | cut -d '.' -f3) -eq "2" ) ]]; then
filial_name=$(ssh username@$i "cat /etc/hostname")
filial_port=$(echo $(snmpwalk -c snmpmod@2 -v 2c $cisco_ip 1.3.6.1.2.1.17.4.3.1.2.$(printf "%d.%d.%d.%d.%d.%d\n" $(echo $(ssh username@$i "ifconfig | grep -i hw | sed -r 's/[[:space:]]+/\t/g' | cut -f5" ) | sed -e 's/://g' | sed 's/\(..\)/\.0x\1/g' | sed -e 's/^\.//' | sed -e 's/\./ /g'))) | cut -d ":" -f2 | sed -re 's/^[[:space:]]//' )
if $first ; then
printf "\n\t{\n"
first=false
else
printf ",\n"
printf "\t{\n"
fi
printf "\t\t\"{#FILIALNAME}\":\t\"$filial_name\",\n"
printf "\t\t\"{#FILIALPORT}\":\t\"$filial_port\"\n"
printf "\t}"
fi
done
printf "\n\t]\n"
printf "}\n"
i get output like this
Code:
{
"data":[
{
"{#FILIALNAME}": "vladimir",
"{#FILIALPORT}": "25"
},
{
"{#FILIALNAME}": "izhevsk",
"{#FILIALPORT}": "21"
},
{
"{#FILIALNAME}": "kazan",
"{#FILIALPORT}": "24"
},
{
"{#FILIALNAME}": "Cheboksari",
"{#FILIALPORT}": "22"
},
{
"{#FILIALNAME}": "Kirov",
"{#FILIALPORT}": "23"
}
]
}
I allways get error "Value should be a JSON object". But it is valid - checked on https://jsonlint.com/ .
zabbix_server_log in debug mode says
In lld_rows_get()
End of lld_rows_get():FAIL
and nothing else.
Where am i wrong ?
p.s. zabbix server v 2.4.1
*facepalm*
Comment