0

I am trying to learn the best practices for checking that Apache and Postgres are running on my server. If either of them have stopped, I want to auto-restart these services. I'm using Ubuntu 12.04 LTS.

My strategy, was to write a cron job that checked that both of these services were alive every 5 minutes, and if they are not, to restart them (and to email me that there was a problem).

I'm unsure if there is a better way to do this. I currently use Fabric to administer the server remotely; and was also wondering if trying to write this all in Python could be an appropriate approach.

Daniel Serodio
  • 249
  • 3
  • 10
celenius
  • 273
  • 1
  • 4
  • 17

2 Answers2

1

Monitoring tools like Zenoss, Nagios, etc, would be better for sure. But if you have like 1 server, they could be overkill.

For Apache, check that you can get a page with wget. For Postgres - well, you can run a query with psql.

Not sure why you are worried about restarting them. I have PostgreSQL and Apache servers which have been running for 5+ years without ever needing to be restarted (except to install updates). These are professional product, they don't just die.

ETL
  • 6,513
  • 1
  • 28
  • 48
0

Monit does exactly what you want to do, in a more standardized manner. I suggest you use it instead of rolling your own solution.

Daniel Serodio
  • 249
  • 3
  • 10