{"id":19431979,"url":"https://github.com/naskio/monit-docker","last_synced_at":"2025-04-14T17:42:33.196Z","repository":{"id":107851733,"uuid":"445756596","full_name":"naskio/monit-docker","owner":"naskio","description":"Monit setup for docker single-host monitoring (host, docker daemon and docker containers) with UI","archived":false,"fork":false,"pushed_at":"2022-01-20T08:50:37.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T17:42:17.930Z","etag":null,"topics":["config","container","container-monitoring","docker","docker-compose","mmonit","mmonit-docker","mmonit-free","monit","monitoring","monitoring-tool","server","ui","vps","vps-setup"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/naskio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-08T07:43:44.000Z","updated_at":"2024-10-30T13:02:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"d38214ec-ce1a-4a59-94c5-630aa2c53347","html_url":"https://github.com/naskio/monit-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naskio%2Fmonit-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naskio%2Fmonit-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naskio%2Fmonit-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naskio%2Fmonit-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naskio","download_url":"https://codeload.github.com/naskio/monit-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248929867,"owners_count":21184907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","container","container-monitoring","docker","docker-compose","mmonit","mmonit-docker","mmonit-free","monit","monitoring","monitoring-tool","server","ui","vps","vps-setup"],"created_at":"2024-11-10T14:33:31.129Z","updated_at":"2025-04-14T17:42:33.173Z","avatar_url":"https://github.com/naskio.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# monit-docker\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/naskio/monit-docker\"\u003e\n    \u003cimg src=\"https://mmonit.com/monit/img/logo@2x.png\" alt=\"Logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e\n\n\u003ch3 align=\"center\"\u003emonit-docker\u003c/h3\u003e\n  \u003cp align=\"center\"\u003e\n    monit setup for docker daemon and containers\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/naskio/monit-docker\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/naskio/monit-docker/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/naskio/monit-docker/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n[![LinkedIn][linkedin-shield]][linkedin-url]\n\nmonitor your docker daemon and containers that are running inside a single host (VPS) using `monit` (will be running in\nthe host machine)\n\n# Table of Contents\n\n- [Installation](#installation)\n    * [Check monit installation](#check-monit-installation)\n- [Configuration](#configuration)\n    * [Receiving alerts by email](#receiving-alerts-by-email)\n    * [collector](#collector)\n    * [Monit UI](#monit-ui)\n        + [Check UI setup](#check-ui-setup)\n    * [Include Monit service configuration](#include-monit-service-configuration)\n- [Monit Docker](#monit-docker)\n- [Monit docker containers](#monit-docker-containers)\n- [M/Monit alternative](#m-monit-alternative)\n    * [custom collector](#custom-collector)\n    * [Visualizing Monit data](#visualizing-monit-data)\n- [Contributing](#contributing)\n- [License](#license)\n    * [Contact](#contact)\n    * [Acknowledgments](#acknowledgments)\n\n\u003csmall\u003e\u003ci\u003e\u003ca href='http://ecotrust-canada.github.io/markdown-toc/'\u003eTable of contents generated with\nmarkdown-toc\u003c/a\u003e\u003c/i\u003e\u003c/small\u003e\n\n# Installation\n\n- Install monit:\n\n```\n# Install monit in the host machine\napt update \u0026\u0026 apt install monit\n# chage permissions\ncd /etc/monit/\nchmod 700 /etc/monit/monitrc\n# restart\nsystemctl restart monit\n```\n\n- Enable monit: `systemctl enable monit`\n\n## Check monit installation\n\n```\nmonit -V\ncurl -I http://localhost:2812/\n```\n\nget services status:\n\n```\nmonit status\n```\n\n# Configuration\n\nEdit `/etc/monit/monitrc` using `vi` or `nano`:\n\n```\nnano /etc/monit/monitrc\n```\n\n- Add the following lines:\n\n```\nset daemon 120 # check every 120 seconds\n    with start delay 240 # delay first check\n\nset log /var/log/monit.log\n\nset idfile /var/lib/monit/id\n\nset statefile /var/lib/monit/state\n\nset eventqueue\n  basedir /var/lib/monit/events # set the base directory where events will be stored\n  slots 100                     # optionally limit the queue size\n```\n\n## Receiving alerts by email\n\nadd the following lines:\n\n```\nset mailserver \u003cSMTP_HOST\u003e port \u003cSMTP_PORT\u003e\n             username \"\u003cSMTP_USERNAME\u003e\" password \"\u003cSMTP_PASSWORD\u003e\"\n             using tls\n             with timeout 60 seconds\n```\n\nExample:\n\n```\nset mailserver smtp-relay.sendinblue.com port 587\n             username \"\u003cSMTP_USERNAME\u003e\" password \"\u003cSMTP_PASSWORD\u003e\"\n             using tls\n             with timeout 60 seconds\nset mail-format { from: \u003cFROM_EMAIL\u003e }\nset alert \u003cRECEIVER_EMAIL\u003e not on { instance, action } # Do not alert when Monit starts, stops or performs a user initiated action.\n```\n\n## collector\n\nThe collector is responsible for receiving the data from monit, and storing it in a database. We need to specify the\ncollector to use by adding the following lines:\n\n```\nset mmonit \u003cWEB_HOOK_URL\u003e\n         with timeout 30 seconds              # Default timeout is 5 seconds\n         and register without credentials     # Don't send monit credentials (needed only if used with M/Monit)\n```\n\nthe WEB_HOOK_URL should be a valid URL that will receive `POST` data from monit (example M/Monit collector).\n\nWEB_HOOK_URL example:\n\n```\nhttps://\u003cHOST\u003e/webhook/monitcollector/collector\n# or with activated Basic Auth\nhttps://\u003cBASIC_AUTH_USERNAME\u003e:\u003cBASIC_AUTH_PASSWORD\u003e@\u003cHOST\u003e/webhook/monitcollector/collector\n```\n\n## Monit UI\n\nadd the following lines to enable Monit http UI:\n\n```\nset httpd port 2812 and\n  use address localhost  # only accept connection from localhost (drop if you use M/Monit or if you want to expose the UI to the public)\n  allow \u003cMONIT_USER\u003e:\u003cMONIT_PASSWORD\u003e      # require user 'admin' with password 'monit'\n```\n\nThe UI can be accessed at `http://localhost:2812/` or exposed to the public using a reverse proxy (Nginx, Caddy,\ntraefik, Apache, etc).\n\n\u003e You can use [qoomon/docker-host](https://github.com/qoomon/docker-host) to expose the UI to the public while using [jwilder/nginx-proxy](https://hub.docker.com/r/jwilder/nginx-proxy).\n\n### Check UI setup\n\nrun the following command to check the UI setup:\n\n```\ncurl -I http://localhost:2812/\n```\n\n## Include Monit service configuration\n\nadd the following lines:\n\n```\ninclude /etc/monit/conf.d/*\ninclude /etc/monit/conf-enabled/*\n```\n\n\u003e this step is required to enable monit to monitor the services since the configuration is not included in the monitrc file.\n\n--------------------------------------------------------------------------------\n\n# Monit Docker\n\nTo monitor the docker daemon and containers, you need to copy `conf.d` and `scripts` folders from the `monit-docker`\nto `/etc/monit/conf.d` and `/etc/monit/scripts` folders. It also includes monitoring for the host resources (Memory,\nCPU, Disk, etc) with alerts.\n\nEdit the configurations `/etc/monit/conf.d` and the scripts `/etc/monit/scripts` for more customization.\n\n```\n/etc/monit/conf.d/docker.conf # docker monitoring\n/etc/monit/conf.d/fs.conf # filesystem monitoring (DISK)\n/etc/monit/conf.d/host.conf # host monitoring (CPU, Memory)\nand the scripts:\n/etc/monit/scripts/check_docker.sh # check docker status\n```\n\n--------------------------------------------------------------------------------\n\n# Monit docker containers\n\nadd a new script to `/etc/monit/scripts` folder named `check_docker-container_\u003cCONTAINER_NAME\u003e.sh`:\n\n```\n#! /bin/bash\ndocker top \"\u003cCONTAINER_NAME\u003e\"\nexit $?\n```\n\nadd a config file to `/etc/monit/conf.d` folder named `docker-container_\u003cCONTAINER_NAME\u003e.conf`:\n\n```\nCHECK PROGRAM \u003cCONTAINER_NAME\u003e WITH PATH /etc/monit/scripts/check_docker-container_\u003cCONTAINER_NAME\u003e.sh\n              START PROGRAM = \"/usr/bin/docker start \u003cCONTAINER_NAME\u003e\"\n              STOP PROGRAM = \"/usr/bin/docker stop \u003cCONTAINER_NAME\u003e\"\n              IF status != 0 FOR 3 CYCLES THEN RESTART\n              IF 2 RESTARTS WITHIN 5 CYCLES THEN UNMONITOR\n```\n\nor using docker-compose:\n\n```\nCHECK PROGRAM \u003cCONTAINER_NAME\u003e WITH PATH /etc/monit/scripts/check_docker-container_\u003cCONTAINER_NAME\u003e.sh\n              START PROGRAM = \"cd \u003cDOCKER_COMPOSE_PARENT_DIR\u003e  \u0026\u0026 /usr/local/bin/docker-compose up -d\"\n              STOP PROGRAM = \"cd \u003cDOCKER_COMPOSE_PARENT_DIR\u003e  \u0026\u0026 /usr/local/bin/docker-compose down\"\n              IF status != 0 FOR 3 CYCLES THEN RESTART\n              IF 2 RESTARTS WITHIN 5 CYCLES THEN UNMONITOR\n```\n\n\u003e make suer that your container has the name \u003cCONTAINER_NAME\u003e\n\n\n\n--------------------------------------------------------------------------------\n\n# M/Monit alternative\n\n## custom collector\n\nUsually we use the solution M/Monit in order to monitor multiple hosts.\n\nIf we want to have a free solution, we can use a custom `collector` that will receive monit data and store it in a\ndatabase (InfluxDB, timescaleDB, MongoDB or any db).\n\nThe collector is a webhook that will listen for monit events (POST requests), parse the data and store it.\n\n## Visualizing Monit data\n\nOnce stored, the data can be displayed in a web UI or using Grafana, Kibana, Prometheus, etc.\n\nWe can use this technique to monitor a single host or a cluster of hosts (single or multiple monit).\n\n--------------------------------------------------------------------------------\n\n# Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any\ncontributions you make are greatly appreciated.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also\nsimply open an issue with the tag \"enhancement\". Don't forget to give the project a star! Thanks again!\n\n- Fork the Project Create your Feature Branch (git checkout -b feature/AmazingFeature)\n- Commit your Changes (git commit -m 'Add some AmazingFeature')\n- Push to the Branch (git push origin feature/AmazingFeature)\n- Open a Pull Request\n\n# License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n## Contact\n\nNask - [@naskdev](https://twitter.com/naskdev) - hi@nask.io\n\nProject Link: [https://github.com/naskio/monit-docker](https://github.com/naskio/monit-docker)\n\n## Acknowledgments\n\n* [monit](https://mmonit.com/monit/)\n* [Using monit to monitor Docker Containers](https://jon.sprig.gs/blog/post/1738)\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n\n[contributors-shield]: https://img.shields.io/github/contributors/naskio/monit-docker.svg?style=for-the-badge\n\n[contributors-url]: https://github.com/naskio/monit-docker/graphs/contributors\n\n[forks-shield]: https://img.shields.io/github/forks/naskio/monit-docker.svg?style=for-the-badge\n\n[forks-url]: https://github.com/naskio/monit-docker/network/members\n\n[stars-shield]: https://img.shields.io/github/stars/naskio/monit-docker.svg?style=for-the-badge\n\n[stars-url]: https://github.com/naskio/monit-docker/stargazers\n\n[issues-shield]: https://img.shields.io/github/issues/naskio/monit-docker.svg?style=for-the-badge\n\n[issues-url]: https://github.com/naskio/monit-docker/issues\n\n[license-shield]: https://img.shields.io/github/license/naskio/monit-docker.svg?style=for-the-badge\n\n[license-url]: https://github.com/naskio/monit-docker/blob/master/LICENSE.txt\n\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n\n[linkedin-url]: https://linkedin.com/in/nask\n\n[product-screenshot]: https://mmonit.com/monit/img/logo@2x.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaskio%2Fmonit-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaskio%2Fmonit-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaskio%2Fmonit-docker/lists"}