Mar 18, 2009

Monit start/stop problem from the command line

Monit is a great tool to monitor various UNIX-like services and to take appropriate actions when they fail. And I've been using it with a great success to monitor Checkvist server. But, as with any tool, there are some issues.

I've spent some noticeable time trying to figure out why monit's command line actions do not work. All of the start, stop, restart actions did nothing. Monit's log didn't contain any trace of my attempts to change state of services.

After some browsing and googling and reading docs I've found the reason of the problem: I've enabled HTTP access to monit only in read-only mode, like this:
set httpd port 3111
allow user:user read-only

And that was the problem. For command line commands to work, the first 'allow' line must not contain 'read-only' option!
This is written in the Monit docs, but not in FAQ:

NB! a Monit client will use the first username:password pair in an allow list and you should not define the first user as a read-only user. If you do, Monit console commands will not work.
If the Monit command line interface is being used, at least one cleartext password is necessary. Otherwise, the Monit command line interface will not be able to connect to the Monit daemon server.

So the solution was to change HTTP settings to:
set httpd port 3111
allow user123:user321 # actually, here goes really cryptic credentials, I don't use them anyway
allow user:pwd read-only

I hope this will save some time for those having the same problem.
Post a Comment