Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron to check that domains are running.

Status
Not open for further replies.

amssb

Programmer
Jul 25, 2009
1
0
0
RO
Hi,

I have a dedicated server (lamp & cpanel) under which I host different web domains:
...

I'm upset because sometimes (rarely, though) I discovered (by opening in the browser) that my domains did not work and I had to restart apache using my root privileges.

Do you have any idea how can I automatically check if such a situation occurs again? A cron job or something like that?

Thanks a lot for your time,
Sorin
 
It actually does work great, I just tried it on one of my servers.
 
Hi

I think that is a bad approach. Just because the process exists not means that it actually does its job. I would do something like this :
Bash:
[COLOR=chocolate]read[/color] protocol response message [teal]<<<[/teal] [green][i]"$( netcat -w 5 $HOSTNAME 80 <<< $'GET / HTTP/1.1[/i][/green][lime][i]\n[/i][/lime][green][i]Host: $HOSTNAME[/i][/green][lime][i]\n[/i][/lime][green][i]Connection: close[/i][/green][lime][i]\n[/i][/lime][green][i]' )"[/i][/green]

[b]if[/b] [teal][[[/teal] [green][i]"$response"[/i][/green] [teal]!=[/teal] [green][i]'200'[/i][/green] [teal]]];[/teal] [b]then[/b]
  /etc/init[teal].[/teal]d/httpd stop
  sleep [purple]3[/purple]
  /etc/init[teal].[/teal]d/httpd start
[b]fi[/b]
This exact syntax will work only with [tt]bash[/tt].

Sorin, maybe the best would be to take a look at your distribution's package list. Is possible to have such monitoring software there.


Feherke.
 
Hi Sorin,

I would consider speaking with your host about setting up monitor pages for each of the domains or use a 3rd party monitoring system that checks the site/page for uptime. As far as actually monitoring software Nagios is one, but may be overkill and your host should have the ability to configure individual monitors. Typically these require a test page ( and reference a "success", etc. string to be outputted to the page that the monitor checks for. If its not found the alert goes off to be investigated.


-Brendan

Brendan Murtagh - HostMySite.com
Technical Support Representative
bmurtagh@hostmysite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top