Ad Widget

Collapse

How to configure auto-update IP address in the profile of the active host?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AlexOdinzoff
    Junior Member
    • Jul 2019
    • 8

    #1

    How to configure auto-update IP address in the profile of the active host?

    Good day!

    Zabbix server version 4.2.5.

    Remote commands must be executed on a host with an active agent, but when changing the IP address this becomes impossible.
    'Network discovery' and 'Action - Auto-registration' are configured and work correctly. The host is automatically added to the server and the execution of remote commands is fully completed. BUT after changing the IP address on the host - remote commands do not work.

    How fix it?
    'Action-Auto-registration' is also responsible for updating the IP address on the host or need to configure something else for this?
  • noyuura
    Junior Member
    • Sep 2019
    • 2

    #2
    Same question. Is it possible to update host ip address somehow when using active agent? Maybe using some kind of trigger and server script combination?

    Comment

    • kloczek
      Senior Member
      • Jun 2006
      • 1771

      #3
      Zabbix identifies exact host not by IP (which is part of the zabbix host interface definition) but by the its name.
      By default name of the host is the name which returns Hostname agent configuration parameter.
      That parameter is by defaut is mapped to HostnameItem=system.hostname.
      In other words in your case it must be like this that after change IP (over DHCP or restart with completly different IP) what returns hostname command is changeing as well and by this is not possible to update existing zabbix host interface. As result new host is created by autoregistration process and zabbix proxy /server is able to deliver to the agent message "please execute something on Host_A" because exactly the same host started announcing its presence under new name.

      Internal design of the zabbix actually is probably perfect to solve such dilemmas
      To solve that you have few options:
      - hardcode hostname in /etc/hostname (if it is Linux .. in case of other OSes it will other way) and block update /etc/hostname file on renew DHCP lease
      - if hostname is updated and something outside of the monitored host like asset tracker can provide fixed hotname you can use HostnameItem=system.run[/command/to/obtain/my/fixed/hostname]
      - you can as well chage straight agent Hostname configuration param to not touch anything from above and to put fixed name which will be used on communication with zabbix proxy/server to query them aboiut what needs to be monitored over active agent on the host with changing time to time zabbix host interface.
      http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
      https://kloczek.wordpress.com/
      zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
      My zabbix templates https://github.com/kloczek/zabbix-templates

      Comment

      • noyuura
        Junior Member
        • Sep 2019
        • 2

        #4

        Thank you for answer, it help me a lot. But anyway, some things are still not clear for me:

        1. Host is distinguished exactly by it's name, right?
        2. I have a host configured with active agent. No passive checks at all.
        3. Autoregistration works ok, host is registered, templates linked, data is flowing.
        4. When I shutdown the host, wait for some time and start it again, then the host is getting new IP from DHCP server.
        5. Hostname is the same, host is autoregistered, templates assigned, data flowing, all clear
        6. But host "Agent interfaces" parameter is not updated, it is still the same - previous IP address of host.

        Can you tell me, which process, actually, is responsible for populating this "Agent interfaces" fields?
        I am able to manually update it using Zabbix web interface ("Configuration" - "host" - <host> - "Agent interfaces"), but is it possible to do this automatically?
        Looks like interface ip addresses are stored in DB "interface" table, but I don't like the idea of messing with Zabbix DB via some kind of side script, maybe there are some kind of "legal" methods available?

        Or maybe it is better to switch to "DNS name", as we are already using DDNS populated by DHCP server, so DNS records are always up to date?

        Comment

        • ITIC007
          Junior Member
          • Oct 2018
          • 19

          #5
          I have also this case scenario --- My hosts shutsdown and at boot it gets a different IP address. The hostname (and all the agent config file) remains the same, only the dynamic IP changed.

          How can I auto update the IP interface in the agent for an active Zabbix agent??

          Comment

          • ipguy
            Junior Member
            • Nov 2010
            • 12

            #6
            two year old thread but i need to ask, is there a workaround for this ?

            Comment

            • gkj-mkj
              Junior Member
              • Oct 2020
              • 1

              #7
              Facing same issue with my zabbix docker containers. My temp workaround was to use the docker container's alias "zabbix-agent" and select DNS instead of IP.

              Comment

              • Achutharaman
                Junior Member
                • May 2021
                • 2

                #8
                Is there any solution for this dynamic IP of the host?

                Comment

                • cyber
                  Senior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Dec 2006
                  • 4806

                  #9
                  Zabbixx turns to hosts using IP-s by default... but there is a way...

                  USING DNS AS DEFAULT INTERFACE
                  HostInterface and HostInterfaceItem

                  allow to specify a custom value for the host interface during autoregistration.
                  More specifically, they are useful if the host should be autoregistered with a DNS name as the default agent interface rather than its IP address. In that case the DNS name should be specified or returned as the value of either HostInterface or HostInterfaceItem parameters. Note that if the value of one of the two parameters changes, the autoregistered host interface is updated. So it is possible to update the default interface to another DNS name or update it to an IP address. For the changes to take effect though, the agent has to be restarted.

                  Comment

                  • sur5r
                    Junior Member
                    • Jul 2024
                    • 1

                    #10
                    We recently came across the same problem. We also found out there's a feature request for this already: https://support.zabbix.com/browse/ZBXNEXT-8231. It might be worth upvoting it for those that would like to see this implemented.

                    Comment

                    Working...