Ad Widget

Collapse

Zabbix URL Ping - check if IP address changes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LukeAB93UK
    Member
    Zabbix Certified Specialist
    • Jun 2023
    • 72

    #1

    Zabbix URL Ping - check if IP address changes

    Hello,

    I am curious as I have had a request come in from a Sys admin.

    They want to know if a certain url fails over to the backup host by having Zabbix ping the IP Address and report the result and if it changes to a different IP address it will then alert with a trigger I write that it has failed over.

    Is it possible to do so with Zabbix without running a custom script?

    Thanks
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    If you ping an IP address, then it either answers or not... it will not change.. If you ping a hosts name, then lookup is done and that IP is pinged... But Zabbix will not catch changes there, as it will record either ping succeeded or not... 0 or 1...

    Comment

    • LukeAB93UK
      Member
      Zabbix Certified Specialist
      • Jun 2023
      • 72

      #3
      Originally posted by cyber
      If you ping an IP address, then it either answers or not... it will not change.. If you ping a hosts name, then lookup is done and that IP is pinged... But Zabbix will not catch changes there, as it will record either ping succeeded or not... 0 or 1...
      Hmm. I need to know if the URL pings from a different IP address and has failed over to the secondary host. Is there anyway to do that as both IPs are always pingable.

      Comment

      • markosa
        Senior Member
        Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
        • Aug 2022
        • 104

        #4
        So, you have host name aa.bb.com? It may respond from IP 1.2.3.4 (main) or 4.5.6.7 (spare) and you want to know when it changed from main to spare? External check with fping might do it, something like this: fping -A -d aa.bb.com and then you would make trigger when IP changed from fping output. Or, do you want to know if web-service has changed host?

        Comment

        • LukeAB93UK
          Member
          Zabbix Certified Specialist
          • Jun 2023
          • 72

          #5
          Originally posted by markosa
          So, you have host name aa.bb.com? It may respond from IP 1.2.3.4 (main) or 4.5.6.7 (spare) and you want to know when it changed from main to spare? External check with fping might do it, something like this: fping -A -d aa.bb.com and then you would make trigger when IP changed from fping output. Or, do you want to know if web-service has changed host?
          You are exactly right. I want to know when www.abc.com for example changes from pinging from 1.2.3.4 to 4.5.6.7 so we know its failed over.

          Comment

          • markosa
            Senior Member
            Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
            • Aug 2022
            • 104

            #6
            As you said, both do respond to ping all the time,right? Then you must check service status/availability, for example in case of www-service you could put just static web page to both servers with different contents, server A has it's IP in that page and server B has it's IP and when querying www.abc.com/mystaticpage you would get always page from server which is working and from there you can see and make trigger for change.

            Comment

            • LukeAB93UK
              Member
              Zabbix Certified Specialist
              • Jun 2023
              • 72

              #7
              Originally posted by markosa
              As you said, both do respond to ping all the time,right? Then you must check service status/availability, for example in case of www-service you could put just static web page to both servers with different contents, server A has it's IP in that page and server B has it's IP and when querying www.abc.com/mystaticpage you would get always page from server which is working and from there you can see and make trigger for change.
              I shall propose that idea to the team and see waht they say thank you for the suggestion.

              Comment

              • ISiroshtan
                Senior Member
                • Nov 2019
                • 324

                #8
                Seems a bit extreme for me to setup a seperate page for such monitoring. If your ping of URL changes IP on failover I would assume you have some kind of failover based on DNS name resolution update? If so, you could try to monitrong result of DNS resolution. On Zabbix you could do a small script in extranl scripts folder with code something along the lines
                Code:
                nslookup URL_HERE | grep -A2 URL_HERE | grep Address | grep -oE '([0-9]+\.?)*'
                Test the script if it properly fetches the IP and detects failover. If it works then setup Zabbix External item check and run the script -> setup the trigger for change between last and before last values.
                Last edited by ISiroshtan; 10-08-2023, 14:44.

                Comment

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

                  #9
                  There is an item

                  net.dns.record[<ip>,name,<type>,<timeout>,<count>,<protocol>]​

                  Maybe its worth to investigate....

                  Comment

                  Working...