Hi folks,
I'm wondering what's the best way to share/copy the Zabbix configuration (templates, groups, users, permissions etc) from one Zabbix server to another. I'm looking for an approach I can automate, so that I can do the copy whenever I want to, just by calling a script.
A bit more detail: We have one production Zabbix server which we'll be frequently adding things to (items/templates etc) via the web interface. However, as well as our production Zabbix server, we also have a Zabbix server in each of our other environments (eg preprod/test/dev), and we'd like to have those as up to date as possible, configuration wise.
So although we want to copy the Zabbix configuration across from the production server, we don't want to copy host-specific information or any captured metrics, as each environment will contain different hosts. Another way of putting it, is that we want to be able to setup a 'fresh' Zabbix server but with all of our templates/groups/graphs/alerts/permissions etc ready to go, based on what's currently on our production Zabbix.
Options to do this as I see it:
1) Use the API to grab the configuration data from production, and then apply it to the destination server
+ Using the API is almost always my preferred option. The fact that we can script against Zabbix's API is one of the main reasons we're using it.
- But there doesn't seem to be any export/import API calls.
- So I'd have to call a ton of separate API calls to export and import everything. I may miss things, and/or I'm not sure what kinds of dependencies in data import order there might be etc. So it looks like it might be a lot of work. (and if in the future new configuration elements are adding to Zabbix which would also need copying, we'd need to modify the script)
2) Export of templates/maps/permissions/screens from the Zabbix web interface
+ XML format is easy to manipulate in a script if need be.
+ Zabbix itself deals with knowing how to export/import the configuration data
- Import/export is fiddly to automate: the web interface is designed for humans, not scripts, so isn't the easiest to make use of, may change in the future, etc.
- From personal experience sometimes to get imports to work I've needed to try them several times to get them to complete, so not sure that an automated script would be very reliable.
3) Do something at the database level
+ Presumably I'd have a lot of control, it would be fast etc.
- I don't really want to have any dependency on Zabbix at the database level if I can avoid it. I don't want to have to understand exactly what goes in each of the 88 tables or how the data is structured internally. I don't want to rely on the schema staying the same. etc.
~ Or maybe it's easier/safer than I think? (could I just import the whole database then clear out a few tables which are host/data specific?)
Any thoughts/suggestions?
Any help much appreciated
I'm wondering what's the best way to share/copy the Zabbix configuration (templates, groups, users, permissions etc) from one Zabbix server to another. I'm looking for an approach I can automate, so that I can do the copy whenever I want to, just by calling a script.
A bit more detail: We have one production Zabbix server which we'll be frequently adding things to (items/templates etc) via the web interface. However, as well as our production Zabbix server, we also have a Zabbix server in each of our other environments (eg preprod/test/dev), and we'd like to have those as up to date as possible, configuration wise.
So although we want to copy the Zabbix configuration across from the production server, we don't want to copy host-specific information or any captured metrics, as each environment will contain different hosts. Another way of putting it, is that we want to be able to setup a 'fresh' Zabbix server but with all of our templates/groups/graphs/alerts/permissions etc ready to go, based on what's currently on our production Zabbix.
Options to do this as I see it:
1) Use the API to grab the configuration data from production, and then apply it to the destination server
+ Using the API is almost always my preferred option. The fact that we can script against Zabbix's API is one of the main reasons we're using it.
- But there doesn't seem to be any export/import API calls.
- So I'd have to call a ton of separate API calls to export and import everything. I may miss things, and/or I'm not sure what kinds of dependencies in data import order there might be etc. So it looks like it might be a lot of work. (and if in the future new configuration elements are adding to Zabbix which would also need copying, we'd need to modify the script)
2) Export of templates/maps/permissions/screens from the Zabbix web interface
+ XML format is easy to manipulate in a script if need be.
+ Zabbix itself deals with knowing how to export/import the configuration data
- Import/export is fiddly to automate: the web interface is designed for humans, not scripts, so isn't the easiest to make use of, may change in the future, etc.
- From personal experience sometimes to get imports to work I've needed to try them several times to get them to complete, so not sure that an automated script would be very reliable.
3) Do something at the database level
+ Presumably I'd have a lot of control, it would be fast etc.
- I don't really want to have any dependency on Zabbix at the database level if I can avoid it. I don't want to have to understand exactly what goes in each of the 88 tables or how the data is structured internally. I don't want to rely on the schema staying the same. etc.
~ Or maybe it's easier/safer than I think? (could I just import the whole database then clear out a few tables which are host/data specific?)
Any thoughts/suggestions?
Any help much appreciated
Comment