{"id":13584022,"url":"https://github.com/M0r13n/mikrotik_monitoring","last_synced_at":"2025-04-06T21:34:04.322Z","repository":{"id":45600356,"uuid":"384741222","full_name":"M0r13n/mikrotik_monitoring","owner":"M0r13n","description":"Monitor your Mikrotik router with Prometheus and Grafana","archived":false,"fork":false,"pushed_at":"2024-09-28T11:51:02.000Z","size":4193,"stargazers_count":300,"open_issues_count":4,"forks_count":38,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-04T17:05:17.053Z","etag":null,"topics":["home-automation","internet","mikrotik","monitoring","prometheus"],"latest_commit_sha":null,"homepage":"","language":"Makefile","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/M0r13n.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":"2021-07-10T16:21:59.000Z","updated_at":"2025-04-04T07:21:39.000Z","dependencies_parsed_at":"2024-02-01T05:55:04.038Z","dependency_job_id":"e1b69c6a-2ccd-4247-b24b-e117cff6ec22","html_url":"https://github.com/M0r13n/mikrotik_monitoring","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/M0r13n%2Fmikrotik_monitoring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M0r13n%2Fmikrotik_monitoring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M0r13n%2Fmikrotik_monitoring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M0r13n%2Fmikrotik_monitoring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/M0r13n","download_url":"https://codeload.github.com/M0r13n/mikrotik_monitoring/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557146,"owners_count":20958037,"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":["home-automation","internet","mikrotik","monitoring","prometheus"],"created_at":"2024-08-01T15:03:57.849Z","updated_at":"2025-04-06T21:34:00.121Z","avatar_url":"https://github.com/M0r13n.png","language":"Makefile","funding_links":[],"categories":["Makefile"],"sub_categories":[],"readme":"# Monitor your Mikrotik router with Prometheus and Grafana\n\nUse Grafana \u0026 Prometheus to monitor Mikrotik devices. This projects serves as a ready to use blueprint for monitoring based on Docker. It is designed and tested to be run on Raspberry Pis.\n\n## Features\n\n- System Health Monitoring\n  - disk usage\n  - CPU load\n  - memory usage\n  - public IP address (IPv4 \u0026 IPv6)\n  - system uptime\n  - temperature\n  - voltage monitoring\n- Interface Monitoring\n  - traffic (bit/s)\n  - traffic (packets/s)\n  - per interface graphs\n- Latency Monitoring\n  - customizable ICMP and/or UDP pings\n  - packet loss\n- DHCP Monitoring\n  - active leases\n  - MAC addresses, host names, addresses\n- Network Monitoring\n  - routes\n  - interfaces errors\n  - interface states\n  - PoE states\n- Firewall Monitoring\n  - rules traffic\n  - logged rules traffic\n  - Ipv4 \u0026 IPv6\n  - bandwidth\n  - active users\n- Wireless Monitoring\n  - noise floor\n  - TxCCQ\n  - client devices\n  - number of clients\n  - traffic\n  - signal strength\n  - signal to noise ratio\n- Netwatch\n- CAPsMAN Monitoring\n  - remote CAPS\n  - registrations\n  - clients\n  - frequencies\n  - signal strength\n  - traffic\n\n## Setup\n\n- Router running RouterOS 7.x.x\n- Raspberry Pi 4 with 2 gb RAM (other PIs may also work, but I wanted ARM 64 bit)\n- before opening a new issue, please take a look at the [FAQ](#FAQ)\n\n## Demo pictures\n\n![General system stats](./doc/system.png)\n\n\u003cdetails\u003e\u003csummary\u003eShow more images\u003c/summary\u003e\n\n![Network](./doc/network.png)\n![Latency](./doc/latency.png)\n![Netwatch](./doc/netwatch.png)\n![Firewall](./doc/firewall.png)\n![WiFi](./doc/wifi.png)\n![Interfaces](./doc/interfaces.png)\n\n\u003c/details\u003e\n\n## Installation\n\n## Mikrotik Router\n\nAt first you need to prepare your router.\n\nCreate a group on the device that has API and read-only access:\n\n`/user group add name=prometheus policy=api,read,winbox,test`\n\nCreate a user that is part of the group:\n\n`/user add name=prometheus group=prometheus password=TOP_SECRET`\n\n## Prepare Raspi\n\nYou need Ubuntu Server for ARM 64 bit in order to use this setup. You may also use Raspian, but then you are limited to 32bit ARM executables. This would mean, that you need to compile the `mikrotik-exporter` by hand, because there are no pre built 32-bit Docker images.\n\nYou need to execute the following steps on the target machine itself (e.g. Raspberry Pi).\n\nInstall Docker ([official docs](https://docs.docker.com/engine/install/debian/)):\n\n`sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin`\n\n**:warning: Note:** `docker-compose` was originally written in Python, but it was deprecated some time ago. [Migrate to Compose V2](https://docs.docker.com/compose/migrate/).\n\n\u003cdetails\u003e\n\u003csummary\u003eOptional: Build the Docker Image for mktxp\u003c/summary\u003e\n\nIt might be necessary to build the Docker Image for: https://github.com/akpw/mktxp.\nThis is especially the case, if your architecture is not:\n- linux/amd64\n- linux/arm/v7\n- linux/arm64\n\n```bash\n# Get the mktxp repository\ngit clone https://github.com/akpw/mktxp.git\n\n# Go into the newly downloaded repo\ncd mktxp\n\n# Build the docker image\ndocker build . -t leonmorten/mktxp:latest\n```\n\n\u003c/details\u003e\n\nNow get this repo and install all services:\n\n```bash\n# Clone this repo\ngit clone https://github.com/M0r13n/mikrotik_monitoring.git\n\n\n# Go into the cloned directory\ncd mikrotik_monitoring\n\n# Let docker-compose do it's job\ndocker compose up -d\n```\n\nYou may need to adjust the following configuration files and add your own credentials for your router:\n\n- `mktxp/mktxp.conf`\n\n\nDone. You should now be able to open the Grafana dashboard on Port 3000 of your Raspberry Pi.\n\n## Latency Monitoring\n\nThis projects uses the Prometheus Blackbox exporter to measure network latency. By default three targets are configured:\n\n- 1.1.1.1 (Cloudflare)\n- 8.8.8.8 (Google)\n- 9.9.9.9 (IBM)\n\nYou may adjust **blackbox/blackbox.yml** according to your needs.\n\n## Multiple Nodes\n\nIt is possible to monitor multiple (Mikrotik) devices. Just change add as many devices to `mktxp/mktxp.conf` as you want.\n\n## HTTPS\n\nIt is also possible to access the Grafana Dashboard over HTTPS.\nDepending on your security requirements and/or threat model it might be a good idea to enable HTTPS.\n\nGenerate a self signed certificate for your domain:\n\n`sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./nginx/nginx-selfsigned.key -out ./nginx/nginx-selfsigned.crt`\n\nReplace the content of `./nginx/nginx.conf` with:\n\n```txt\nserver {\n  listen 80;\n\tlisten [::]:80;\n\tserver_name _;\n\treturn 301 https://$host$request_uri;\n}\n\nserver {\n  listen 443 ssl;\n  listen [::]:443 ssl;\n  include ssl/self-signed.conf;\n\n  location / {\n   proxy_set_header Host $http_host;\n   proxy_pass http://grafana:3000/;\n  }\n}\n\n```\n\n## AppArmor\n\nUnder `./docker-armor` you can find an AppArmor profile for this stack. To use it, do the following:\n\n```\ncp ./docker-armor /etc/apparmor.d/docker-armor\napparmor_parser -r -W /etc/apparmor.d/docker-armor\ndocker compose -f docker-compose-armored.yml  up -d\n```\n\n## Resources\n\n- [A blog post by Devin Smith that first got me interested](https://blog.devinsmith.co.za/home-internet-grafana-lockdown/)\n- [A somewhat useable Grafana Dashboard](https://grafana.com/grafana/dashboards/10950)\n- [A Prometheus exporter for Mikrotik devices written in Python](https://github.com/akpw/mktxp).\n- [A Prometheus exporter for Mikrotik devices written in Go](https://github.com/nshttpd/mikrotik-exporter)\n- [Prometheus Blackbox exporter](https://github.com/prometheus/blackbox_exporter/blob/master/example.yml)\n\n## FAQ\n\n### Why are my graphs empty?\n\nIt might happen that the Grafana dashboard loads, but the graphs remain empty. If the dashboard loads, but no data is shown, this may be caused by any of the following reasons:\n\n- invalid credentials for the monitored RouterOS device\n    - verify with: `/user/print detail`\n- invalid host and port for the monitored RouterOS device\n    - check that the IP or host name of the monitored device is correct\n- API service disabled on the RouterOS device\n    - verify with `/ip/service/print detail`\n\n### What distinguishes this project from other similar projects?\n\nThis project is only a personal hobby.\nIt do it mainly to learn something and to improve my skills.\nTherefore, the project does not compete with other projects.\nNor do I aim for completeness or perfection.\nThe goal of this project is to develop a monitoring solution for multiple RouterOS devices simultaneously that is resource-efficient and scalable.\n\n### Why you don't use the SNMP for monitoring?\n\nFirstly SNMP based monitoring is painfully slow.\nIn my experience SNMP walks are slow and CPU heavy.\nAnd I am not [alone with this](https://forum.mikrotik.com/viewtopic.php?t=132304).\nIn my experience the API is much faster and produces less stress on the CPU of the monitored device.\n\nSecondly I never really got used to the way that SNMP metrics and queries are structured.\nI find them very hard to read.\n\nIn addition, the API offers a lot of flexibility.\nAny command can be executed on RouterOS via the API.\nThus it is possible to collect complex metrics.\n\n### I get a PermissionError when running docker-compose up\n\nWhen bind-mounting a directory from the host into a container, files and directories\nmaintain the permissions they **have on the host**. These can not be changed by Docker.\nTypically, a bind-mounted directory has permissions like these: `rwxrwxr-x`.\nThis means that the container can read from the bind-mounted directory. But it can not\nwrite or modify the mounted files.\n\nThis mostly works fine. But the Prometheus exporter mktxp has a specialty:\nIt may update it's configuration if some keys are missing from the configuration file.\nImagine, that the key `ipv6_firewall` is missing from the **mktxp.conf**. In this case\nmktxp will add `ipv6_firewall=false` to the configuration file instead of failing.\nThis is a helpful feature, but can cause the container to crash, if the user inside\nthe container lacks write permissions.\n\nIn order to resolve this issue, make sure that all keys that mktxp currently supports\nare listed in your **mktxp.conf** file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FM0r13n%2Fmikrotik_monitoring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FM0r13n%2Fmikrotik_monitoring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FM0r13n%2Fmikrotik_monitoring/lists"}