Community discussions

MikroTik App
 
GREG3f
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 83
Joined: Wed Dec 03, 2008 9:52 pm

HTTPD Server monitor/failover

Wed Nov 16, 2011 10:24 pm

I am looking for a way to monitor an in-house web server and if it stops serving pages I want to display a web page/message that says the server is down and we are working on the problem.

The server is on the Lan and I have dstnat for port 80 forwarding to the server.

I know we can use netwatch to monitor the server, but that only helps if the whole server goes down, not just apache.

Is this possible and if so, how would it be done?

Greg
 
fewi
Forum Guru
Forum Guru
Posts: 7734
Joined: Tue Aug 11, 2009 3:19 am

HTTPD Server monitor/failover

Thu Nov 17, 2011 12:37 am

Write a script that fetches a page from the server. Then check if the file exists. If it doesn't then the server is down, so fire your down event. Then delete the file.

Schedule that to run as appropriate.

Keep in mind this will cost you quite a few write cycles on NAND.
Specific answers require specific questions. When in doubt, post the output of "/ip address print detail", "/ip route print detail", "/interface print detail", "/ip firewall export", and an accurate network diagram.
 
User avatar
TealFrog
just joined
Posts: 23
Joined: Sun Oct 02, 2011 11:56 am

Re: HTTPD Server monitor/failover

Thu Nov 17, 2011 9:03 am

I was wondering have you considered a watchdog script or service executing on the server itself monitoring the web server and server process?

Unless the issue is with the server itself or the network and not just the HTTPD service/daemon, then this might prove to be a better option. I don't know your specifics, so it is hard to say, but as previously mentioned a script doing a fetch on the router is going to cost quite a few write cycles on the NAND. The polling frequency is going to have a direct correlation on the write cycles. Of course this becomes a moot point or less of an issue if on board NAND isn't being used.

With a watchdog program executing on the web server, the program can take direct action on the server against the web process, recycling or downing the HTTPD process as needed. Potentially, a second HTTPD process either running on a different TCP port or on a different IP address (same server) could be used. Depending on available resources either a separate server or a virtual server could also be used. Depending on the setup a second HTTPD instance could then be tied to the same content or different content containing the message you described. If using separate IP addresses, the primary web server IP address could then be downed and a ping mechanism at the router could be used to trigger the fail over. Theoretically, you could forgo the second web instance and move the function of displaying the error message to the router. However, as great and flexible a device as Tik routers tend to be, IMO I think it is best if they are left to do what they were designed to do, network and route.

In my experience if the web site demands it, it is best to build in redundancy as there are many options available to do this and if there is a known issue with the HTTPD server failing, then it is best to fix it, though I suspect that this is not the case in this instance.

Regards.
TealFrog
 
richedav
Member Candidate
Member Candidate
Posts: 114
Joined: Mon Dec 13, 2010 12:13 am

Re: HTTPD Server monitor/failover

Thu Nov 17, 2011 11:17 am

Another thread that could really do with a Fetch direct to variable....

Is there a feature request process?

Who is online

Users browsing this forum: DorianGray and 19 guests