This script was originally written by Travis Mathis, from Millicorp back in 2011, for Zabbix 1.8.5. A link to the original posting on the Zabbix forum is
I’ve updated the script to work for Zabbix 2.0 (tested with 2.0.8 and on CentOS 5/6). I’ve also added a number of command-line options to allow this to be run automatically, converted many sections to functions, added ability to specify multiple templates, added ability to specify multiple groups, added IP address validation
-l location -h hostname -i ip address -g group name (if spaces, must be inside quotes) -t template name (if spaces, must be inside quotes)
-d dry run (prints out a complete command line) -q quiet (reduces output)
All parameters are optional. If a value is not specified on the command line, the script will prompt for the value.
Other than checking to verify that a syntactically valid IP address is entered, there is no error checking. If the system has multiple IP addresses, it will select the first one (as returned by ifconfig)
The script has the ability to install the agent which I don’t use; we use CF-Engine to install standard packages on our systems. However, if you would like to use this to install the agent as well, there are a couple of minor changes you will have to make:
- The variable “INSTALL_AGENT” will need to be set to 1
- The function “addZabbixRepo” will need to be updated to whatever repo you want to use.
- The function “install_agent_and_add_port_to_iptables” may need to be modified to install the correct agent packages.
- If you want it to install a basic config file for zabbix, you will also need to update “INSTALL_CONF” and “ZABBIX_CONF”
The dry run option is intended to be used to generate a complete command line which you can then use in a script.
zabbix-create.sh.gz (4.0 KiB, 1,301 hits)