Skip to content

Commit

Permalink
Add support for debug mode monit
Browse files Browse the repository at this point in the history
  • Loading branch information
diogopms committed Feb 5, 2020
1 parent b7b60f6 commit 5f53693
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ENV MONIT_VERSION=5.26.0 \
PATH=$PATH:/opt/monit/bin

COPY slack /bin/slack
COPY pushover /bin/pushover

# Compile and install monit
RUN \
Expand All @@ -23,4 +24,8 @@ RUN \

EXPOSE 2812

COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
ENTRYPOINT ["/entrypoint.sh"]

CMD ["monit", "-I", "-B"]
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,40 @@ Docker documentation: https://docs.docker.com/
- build docker image `docker build -t monit .`
- start monit: `docker run -ti -p 2812:2812 -v $(pwd)/monitrc:/etc/monitrc monit`

## ENV VARS

| ENVs | Description |
|----------------- |---------------------------------------------------------- |
| SLACK_URL | Webhook url for slack notifications (required for slack) |
| PUSH_OVER_TOKEN | Push over api token (required for pushover) |
| PUSH_OVER_USER | Push over api user (requiredfor pushover) |
| DEBUG | If set with 1 it will put monit in verbose mode |

### Docker Hub image

- pull docker image from docker hub: `docker pull diogopms/monit-docker-kubernetes`
- start monit: `docker run -ti -p 2812:2812 -v $(pwd)/monitrc:/etc/monitrc diogopms/monit-docker-kubernetes`
- create a docker container:

```
#Normal mode (support slack and pushover)
docker run -it \
-p 2812:2812 \
-v $(pwd)/monitrc:/etc/monitrc \
-e "SLACK_URL=<SLACK_URL>" \
-e "PUSH_OVER_TOKEN=<PUSH_OVER_TOKEN>" \
-e "PUSH_OVER_USER=<PUSH_OVER_USER>" \
diogopms/monit-docker-kubernetes
#Debug mode
docker run -it \
-p 2812:2812 \
-v $(pwd)/monitrc:/etc/monitrc \
-e "SLACK_URL=<SLACK_URL>" \
-e "PUSH_OVER_TOKEN=<PUSH_OVER_TOKEN>" \
-e "PUSH_OVER_USER=<PUSH_OVER_USER>" \
-e "DEBUG=1" \
diogopms/monit-docker-kubernetes
```

### Example monitrc (Slack)
Expand Down Expand Up @@ -78,6 +98,8 @@ EOF
- [Slack](https://www.slack.com)
- [Pushover](https://pushover.net)

### Kubernetes

### Troubleshooting

If when starting Monit returns the following message: `The control file '/etc/monitrc' permission 0755 is wrong, maximum 0700 allowed`, simply give the appropriate permissions to _monitrc_: `chmod 700 monitrc`.
8 changes: 8 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

if [ "$DEBUG" = "1" ]
then
exec monit -I -B -v
else
exec "$@"
fi

0 comments on commit 5f53693

Please sign in to comment.