Using uptimerobot's webhook with cloudflare to achieve HA (downtime no longer than ~6 minutes)

Discussion in 'Tutorials and Guides' started by black, Jul 25, 2014.

  1. black

    black New Member

    39
    13
    Sep 25, 2013
    The script - https://raw.githubusercontent.com/blackdotsh/UptimeFlare/master/renameMe.php

    License: MIT<br>

    Dependencies: Web Server, PHP, php-curl lib

     

    Setup:

    1. I suggest you rename the php file to something obscure.

    2. Add / change the global vars section. It consists of credentials and other information that needs to be modified to your needs.

    3. Upload this script to the desired server, make sure the script is accessible via the internet.

    4. On uptimeRobot:

            Create a new alert contact and select web hook. For url, put in the url to the php script and add "?key=YourKeySetInThePHPScript&". 

            If my $key was set to HelloWorld and I renamed my script to monitorUP.php which is accessible via 127.0.0.1, then for the url I would put <br>

            http://127.0.0.1/monitorUP.php?key=HelloWorld& Make sure you have the & at the end.

    5. Add this alert type to your websites. It's recommended that you have more than the PHP hook as an alert type, so you can switch it back to the primary server once it's up. With this setup, a website shouldn't have a downtime of more than ~6 minutes, assuming your DNS provider does not cache queries.

     
     
    MannDude likes this.
  2. MannDude

    MannDude Just a dude vpsBoard Founder Moderator

    5,036
    2,633
    Mar 8, 2013
    MannDude
    Oh sweet. I do something similar with StatusCake and Rage4. If StatusCake detect the server is down, things are picked up by a 'failover' server, which basically just says we'll be back soon and has our Twitter stream embedded into it.

    Someone will have to give this a try and let us know how it goes :)
     
  3. black

    black New Member

    39
    13
    Sep 25, 2013
    I should play around with Rage4 more. 

    For dynamic websites, I use rsync to copy the DB over every 6 hours then put the site in read only mode and a message saying this is a backup server, we'll be back soon.
     
  4. MannDude

    MannDude Just a dude vpsBoard Founder Moderator

    5,036
    2,633
    Mar 8, 2013
    MannDude
    That's what I've thought about doing as well, just haven't sat down and done it yet. :)