January 2019
Intermediate to advanced
798 pages
20h 33m
English
One of the possible problems that we need to solve when importing hosts in Zabbix from XML is creating a larger number of hosts. We could use a hackish script like this to generate a Zabbix host XML out of a CSV file:
#!/bin/bash split="%" agent_port=10050 useip=1 [[ -s "$1" ]] || { echo "Usage: pass an input CSV file as the first parameter File should contain data in the following format: hostname,dns,ip,hostgroup,linked_template,agent_port agent_port is optional For groups and templates multiple entries are separated with % First line is ignored (assuming a header)" exit 1 } echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <zabbix_export> <version>4.0</version> <date>$(date "+%Y-%m-%dT%H:%M:%SZ")</date> <hosts>" while read ...Read now
Unlock full access