Question: I find debugging monit to be a major pain. Monit's shell environment basically has nothing in it (no paths or other environment variables). Also, there are no log file that I can find.

The problem is, if the start or stop command in the monit script fails, it is difficult to discern what is wrong with it. Often times it is not as simple as just running the command on the shell because the shell environment is different from the monit shell environment.

What are some techniques that people use to debug monit configurations?

For example, I would be happy to have a monit shell, to test my scripts in, or a log file to see what went wrong.

Answer: 
You can start Monit in verbose/debug mode by adding `MONIT_OPTS="-v"` to `/etc/default/monit` (don't forget to restart; `/etc/init.d/monit restart`).

You can then capture the output using `tail -f /var/log/monit.log`

```
[CEST Jun  4 21:10:42] info     : Starting Monit 5.17.1 daemon with http interface at [*]:2812
[CEST Jun  4 21:10:42] info     : Starting Monit HTTP server at [*]:2812
[CEST Jun  4 21:10:42] info     : Monit HTTP server started
[CEST Jun  4 21:10:42] info     : 'ocean' Monit 5.17.1 started
[CEST Jun  4 21:10:42] debug    : Sending Monit instance changed notification to monit@example.io
[CEST Jun  4 21:10:42] debug    : Trying to send mail via smtp.sendgrid.net:587
[CEST Jun  4 21:10:43] debug    : Processing postponed events queue
[CEST Jun  4 21:10:43] debug    : 'rootfs' succeeded getting filesystem statistics for '/'
[CEST Jun  4 21:10:43] debug    : 'rootfs' filesytem flags has not changed
[CEST Jun  4 21:10:43] debug    : 'rootfs' inode usage test succeeded [current inode usage=8.5%]
[CEST Jun  4 21:10:43] debug    : 'rootfs' space usage test succeeded [current space usage=59.6%]
[CEST Jun  4 21:10:43] debug    : 'ws.example.com' succeeded testing protocol [WEBSOCKET] at [ws.example.com]:80/faye [TCP/IP] [response time 114.070 ms]
[CEST Jun  4 21:10:43] debug    : 'ws.example.com' connection succeeded to [ws.example.com]:80/faye [TCP/IP]

```
By default, monit logs to your system message log and you can check there to see what's happening. 

Also, depending on your config, you might be logging to a different place

```
tail -f /var/log/monit

```

<http://mmonit.com/monit/documentation/monit.html#LOGGING>

Assuming defaults (as of whatever old version of monit I'm using), you can tail the logs as such:

**CentOS:**

```
tail -f /var/log/messages

```

**Ubuntu:**

```
tail -f /var/log/syslog

```

**Mac OSX**

```
tail -f /var/log/system.log

```

**Windows**

Here be Dragons

But there is a neato project I found while searching on how to do this out of morbid curiosity: <https://github.com/derFunk/monit-windows-agent>