Zabbix template bash generator
Jump to navigation
Jump to search
#!/bin/bash set -eu create_item(){ dnshost=$1 fqdn=$2 uuidv4=$(uuid -v 4 | sed 's/-//g') item_line=$(cat <<EOF - uuid: ${uuidv4} name: ${dnshost}_${fqdn} type: EXTERNAL key: 'dnsname-resolve["${dnshost}", "${fqdn}"]' EOF ) echo "${item_line}" } create_header(){ header_line=$(cat <<EOF zabbix_export: version: '6.0' date: '2023-02-10T18:59:20Z' groups: - uuid: 3f372bbb7eca47978fc251a6312cc577 name: Green templates: - uuid: 840d80e8fc84470ba450e5bddb82a736 template: dns-resolver-tests name: dns-resolver-tests groups: - name: Green items: EOF ) echo "${header_line}" } main(){ create_header for dnshost in $(cat dnshosts.txt); do for fqdn in $(cat fqdns.txt); do create_item ${dnshost} ${fqdn} done done } main