i have script which differs only in job name so tried to create LLD in order to avoid creating separate item/UserParameters for every job
i named script get-job.state.sh
i copied this script to zabbix server /usr/lib/zabbix/externalscripts and renamed it to job.list (which is item name specified in UserParameter section in Zabbix agent
i got valid JSON file
Job discovery:

Item prototype

Trigger prototype:

Under trigger protoptype i got error Value should be a JSON object
is there any error in above steps ?
Code:
#!/bin/bash
job=$1
curl -s -H "Accept: application/json" -X GET "http://192.168.253.21:4440/api/20/project/test/executions?authtoken=kH44NoX35bp1zxohgkMtsOIC9H9tw6UI" | jq -r '.|[.executions[] | select(.job.name != null) | select(.job.name|contains("'"$job"'")) ] | sort_by(.id) | reverse | .[0] | [.status, .job.name, ."date-started".date, ."date-ended".date, .job.project] | @csv' | sed 's/,/ /g' >st.txt
while read -r status name startdate enddate project; do
startdate=${startdate//\"/}
stime=$(date -d "${startdate/T/ }" +%s)
enddate=${enddate//\"/}
etime=$(date -d "${enddate/T/ }" +%s)
let elapsed=etime-stime
if [ "$status" == "\"aborted\"" ] && [ "$elapsed" -gt 150 ]; then echo "Cancelled:long execution"
elif [ "$status" == "\"aborted\"" ] && [ "$elapsed" -lt 150 ]; then echo "Aborted"
elif [ "$status" == "\"failed\"" ]; then echo "failed"
#elif [ "$status" == "\"succeeded\"" ]; then echo "success"
elif [ "$status" == "\"succeeded\"" ] && [ "$elapsed" -gt 150 ]; then echo "Success:long execution"
fi
done<st.txt
i named script get-job.state.sh
i copied this script to zabbix server /usr/lib/zabbix/externalscripts and renamed it to job.list (which is item name specified in UserParameter section in Zabbix agent
Code:
[UserParameter=job.list,echo -e "job1\ntjob2" | sed 's/^/{"{#JOB}":"/;s/$/"},/' | tr -cd '[print:]' | sed 's/^/{"data":[/;s/,$/]}/' | /var/lib/zabbix/get-job-state.sh
i got valid JSON file
Code:
{"data":[{"{#JOB}":"job1"},{"{#JOB}":"job2"}]}
Item prototype
Trigger prototype:
Under trigger protoptype i got error Value should be a JSON object
is there any error in above steps ?