News for hackers. Stuff that matters.
Re:Ask HN: A simple tcp monitor ? by spudlyo on Sunday August 02, 2009 @01:25PM (#737720)
Grab the Nagios plugins tarball, build it on linux, and find the check_tcp program. Wrap a little shell program around check_tcp that will either do nothing, or fire off your script depending on the return code of check_tcp. Run this once a minute out of cron. Make sure these scripts won't stack up, by either setting check_tcp's socket timeout to less than 60 seconds, or have the script initially check to make sure no other of its kind are running.
Re:Ask HN: A simple tcp monitor ? by moe on Sunday August 02, 2009 @01:43PM (#737752)
Make sure these scripts won't stack up

And that's exactly why you don't roll these things on your own unless you have a very good reason. Making sure a cronjob doesn't stack up reliably is non-trivial and becomes extremely hairy when the network gets involved. Many people think "I'll just use a lockfile" - think again.

Since for monitoring scripts this kind of reliability is the whole point, I strongly suggest to use something like monit where someone else has already worked out all the little corner cases.

Re:Ask HN: A simple tcp monitor ? by spudlyo on Sunday August 02, 2009 @02:30PM (#737857)
The OP is not likely interested in monitoring software advocacy, he wants "a quick & dirty way to guarantee a good nights sleep" while his buddy is on vacation.

I still think a smart wrapper around check_tcp is the way to do this. Perhaps not out of cron, it can instead be a long running process in a sleep/fork/exec(check_tcp)/waitpid loop.