Ad Widget

Collapse

How can I create Zabbix configuration under some source control system like git?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • c.h.
    Junior Member
    • Dec 2021
    • 29

    #1

    How can I create Zabbix configuration under some source control system like git?

    We've been using Zabbix 5.0.20, and just set up Zabbix 6.0.0 on a test server (postgres + nginx on Ubuntu 18.04).

    Up to this point, our configuration has been fairly trial-and-error, clicking through menus and trying various options until things work; this has led to a fair number of "failed experiments" in the database.

    What we'd like to do is to capture the configuration in git, such that we can edit the files and replay them on a fresh database. This would allow a very granular "undo" and "redo" functionality, with the possibility of doing code reviews etc.

    Is there a nice way to do this? I guess it's possible to dump the configuration tables from postgres and check them into git, but that seems rather crude.

    Thanks!
  • LenR
    Senior Member
    • Sep 2009
    • 1005

    #2
    There is https://github.com/ansible-collections/community.zabbix. I think it would create and maintain a Zabbix configuration, but I don't think it will extract your current configuration.

    I looked at it, but we don't use it. Our networking team has an inventory database and they use it via the Zabbix API to push our network device config to Zabbix. We use autoregistration for our servers, so very few hosts are manually added. We do server host grouping and apply non-standard templates via the GUI.

    Comment

    • c.h.
      Junior Member
      • Dec 2021
      • 29

      #3
      Yes, autoregistration is really useful: I like that I can delete all of the hosts and they'll pop back up in under a minute, and run the various resource discovery processes a few minutes later. I normally nuke everything after refactoring items and triggers into different templates, because rearranging all the hosts through a GUI or writing a script that calls the API is error-prone. Nuking everything is a bit like rebooting your computer to get into a known state.

      As for the ansible rules repository, that's a good idea, although we're not far enough along in our ansible-crafting to know quite how to use them. :-/

      We're also looking at setting up Netbox and importing data from it to Zabbix and Ansible, as Netbox looks like a better way to describe resources.

      The way Kubernetes does its configuration also comes to mind: just write patches and 'apply' them to the global configuration. The patches can reviewed, applied, removed, and stored in git, which are the properties I'm seeking now for Zabbix.

      Thanks!

      Comment

      • lasseoe
        Junior Member
        • Aug 2008
        • 15

        #4
        Originally posted by c.h.

        The way Kubernetes does its configuration also comes to mind: just write patches and 'apply' them to the global configuration. The patches can reviewed, applied, removed, and stored in git, which are the properties I'm seeking now for Zabbix.

        Thanks!
        You're looking for a GitOps'ish kind of way - Besides using the API and writing your own tools, you're probably best off with Ansible as appears it to cover most if not all things.
        If you maintain a proper CMDB it would be relatively straight forward to add in new hosts and devices, simply look it up in CMDB and apply the correct templates based on it's roles defined in CMDB.


        Emc2Net, articles and presentations about SysAdmin, monitoring, trending, automation, performance tuning, security hardening, high availability, disaster recovery, linux, postgresql, zabbix, grafana, elasticsearch, opensearch, fluent-bit, ansible and home for the open source projects Zabbix-CLI and PgBackMan. Archives from the PostgreSQL-ES and Linux-ES projects.


        Go bindings for the Zabbix API. Contribute to zabbix-tools/go-zabbix development by creating an account on GitHub.

        Comment

        • c.h.
          Junior Member
          • Dec 2021
          • 29

          #5
          Thanks for the advice and the links: We're using Ansible, but only for deploying our application, we should use it more fully. I've been using zabbix-cli, but I'm really pleased to see pybix; it looks even better!

          Comment

          Working...