Created
July 11, 2020 22:49
-
-
Save 1977er/ab0723de1a2de9caf95cd1c54df1c81b to your computer and use it in GitHub Desktop.
Zabbix: LowLevelDiscovery json/data wrapper (needed for legacy versions)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: | |
# $ cat input.txt | |
# dom01 | |
# dom02 | |
# dom10 | |
# dom23 | |
# | |
# cat input.txt | ./lld-wrapper.sh "#FOO" | |
# initialize data | |
echo '{"data":[' | |
# read all lines from stdin | |
while read line | |
do | |
arr_lines+="$last " | |
last=$line | |
done < "${2:-/dev/stdin}" | |
# build the first lines | |
for arr_line in $arr_lines; do | |
echo " {\"{$1}\":\"$arr_line\"}," | |
done | |
# build the last line | |
echo " {\"{$1}\":\"$last\"}" | |
# terminate data | |
echo ']}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment