Ask HN: A simple tcp monitor ?
Is anybody aware of the existence of what is probably easiest described as 'nagios light', a simple to use and robust program that fires off a script on a machine if a local port becomes unreachable, hangs or times out?
I'm sure I can whip up something simple but my experience is that such simple things tend to get more complicated than you expect once you start building.
The intended platform is linux.
(
15 comments
| 17 points
| on HN
)
The trick will be just limiting it to simple functionality. Easy for these types of apps to get out of hand.
About ten years ago I wanted to write a windows app that allowed text to appear as a window -- no rectangular frame, menu, or close button. Just text. The text was the window, and there was nothing else but the text.
I figured out how to do it, and ended up writing something that had a properties page that looked like it could launch Trident Missiles. Fun project, but definitely overkill for what I needed.
Nagios will do the job but it's total overkill. Ideally a simple solution such as:
should do the trick (resource, checkinterval, action)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.
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.
I use it in a medium to high volume production environment [2], and it has done a very good job at getting our lighttpd and nginx back up on the air whenever we experience peaks above the normal workload.
[1] http://god.rubyforge.org/
[2] http://video.nrkbeta.no/
http://haproxy.1wt.eu/