App to test tcp service

Hi,

I search an application, or library that tests a tcp service (is alive ?) and execute an action if not. What I want to do exactly?I want to build a PHP application cloud service. I have many servers. Each runs many applications with apache and pph-fpm, If one server goes down, I want to start a new php-fpm instance and reload the web application in all servers that are up. I hope you understand :)

I don't want a nagios. Just a little daemon that detects very fast if a tcp service (HTTP) is down on a server and executes a script.


Thanks you.
 
If you want something complex, look at sysutils/heartbeat

But I think it is better to write something simple in a shell script with the nc:

Code:
nc -z [url]www.example.com[/url] 80 || echo 'cannot connect'
or
Code:
echo -e "GET / HTTP/1.0\n\n" | nc [url]www.example.com[/url] 80

Or you can use the fetch to download a web page, parse its content by grep or sed and then run your command.

Code:
fetch -T 5 -o /dev/null -q [url]http://www.example.com/[/url] 2> /dev/null || echo 'cannot fetch'

(replace echo with your own command)

You can run it from cron each minute, or use it in an endless while loop
 
Back
Top