Monitoring URL

Is there an easy way to monitor the health of an ejabberd server from a URL that can be integrated into a production monitoring system? In the rest of our production systems, we typically provide a URL with the application that provides a page called Monitor.htm which returns a 1 or 0 depending on the health of the system. In the context of ejabberd, it would probably be enough to make sure Mnesia is up and running, and maybe select a record from a table, although I'm sure you could come up with a much more comprehensive list.

I was thinking we could just add something like the following to to mod_http_bind.erl:

process('Monitor.htm', #request{method = 'GET',
data = []}) ->
try(mnesia:transaction(fun()->mnesia:read(config,hosts) end))
catch
success -> 1
failure -> 0

However, my erlang skills are very new, and I seriously doubt that's even valid erlang. Is there an existing module that would do something similar to this? Or would there be someone with much better erlang skills than mine who might be able to provide a snippet of code similar to the above, but have it actually work. :)

Yes, it would be possible to

Yes, it would be possible to add the feature with just a few lines similar to what you wrote.

But I wrote it as a stand-alone module, with more hard-coded tests, and configurable path. See http://www.ejabberd.im/mod_monitor_web

Syndicate content