Compare commits

...

14 commits

Author SHA1 Message Date
IgorKha
da35426cfd
Update README.md 2023-12-21 13:50:05 +05:00
Lauri Tirkkonen
2550ba1fe0
RX/TX Sum: make unit bytes, not bits (#33)
the metrics are called mtxrInterfaceStats{Rx,Tx}Bytes, so bits is not
correct
2023-11-17 14:40:01 +05:00
Kim SK
f741901f03
Update snmp.yml (#32)
Because of snmp_exporter configuration file format change, changed snmp.yml. (https://github.com/prometheus/snmp_exporter/blob/main/auth-split-migration.md)
2023-09-21 12:19:09 +05:00
Yovko Yovkov
aa802b1c36
better ifname regexp (#23)
Before regexp for isolating interface names was relying on the the next tag in query to be exactly "instance", which were generating few issues:
  - if there is another tag starting with the word "interface"
  - if the next tag is not "interface"
then the interface name extracted are not valid.

The proposed regexp is solving that issues
2022-10-12 23:07:51 +03:00
IgorKha
1f8ddb8254 fix actions 2022-07-27 16:22:04 +03:00
IgorKha
8dbeac2110 fix actions 2022-07-27 16:18:36 +03:00
IgorKha
0e616af363 fix actions 2022-07-27 16:15:37 +03:00
IgorKha
aafa4316d5 updated grafana version 2022-07-27 15:53:18 +03:00
Whemoon Jang
f1107cf89f
Fix broken panels when prometheus is not default datasource. (#15)
* Fill omitted datasource on some panels

* Fill omitted datasource on some panels
2022-07-27 14:19:25 +03:00
IgorKha
5b3213838b small improvements 2022-06-21 21:09:02 +03:00
IgorKha
4ad3af58e0 small changes into workflow 2022-06-21 17:37:51 +03:00
IgorKha
b7a80c3106 cosmetic refactoring
and small fix shell script
2022-06-21 17:12:24 +03:00
IgorKha
3adcdd666a fix issue #9 (run arm and other arch) 2022-06-21 17:09:21 +03:00
igorkha
51ca2896de
added 60GHz monitoring
Signed-off-by: igorkha <hahabahov@yandex.ru>
2022-01-31 19:28:07 +03:00
12 changed files with 8443 additions and 5310 deletions

5
.env
View file

@ -1,4 +1 @@
GF_ADMIN_USER=admin
GF_ADMIN_PASSWORD=mikrotik
CURRENT_USER=root
MIKROTIK_IP=192.168.88.1
CURRENT_USER=1000:1000

View file

@ -24,11 +24,10 @@ jobs:
run: curl -fsSL https://raw.githubusercontent.com/IgorKha/Grafana-Mikrotik/master/run.sh | bash -s --
- name: Test Grafana
run: sleep 5 && curl -ILsS --retry 5 --retry-delay 2 "http://localhost:3000/login"
run: sleep 10 && curl -GLsS --retry 5 --retry-connrefused --retry-delay 2 'http://localhost:3000/api/health'
- name: Test Prometheus
run: curl -ILsS --retry 5 --retry-delay 2 "http://localhost:9090"
run: curl -GLsS --retry 5 --retry-delay 2 "http://localhost:9090/-/ready"
- name: Test snmp_exporter
run: curl -ILsS --retry 5 --retry-delay 2 "http://localhost:9116"

3
.grafana Normal file
View file

@ -0,0 +1,3 @@
GF_SECURITY_ADMIN_USER=admin
GF_SECURITY_ADMIN_PASSWORD=mikrotik
GF_USERS_ALLOW_SIGN_UP=false

1
.prometheus Normal file
View file

@ -0,0 +1 @@
MIKROTIK_IP=192.168.88.1

File diff suppressed because it is too large Load diff

View file

@ -1,22 +1,26 @@
# Grafana-Mikrotik
![logo](https://repository-images.githubusercontent.com/366494855/c62052b8-17c2-47f2-a3ae-0e397a3ef074)
![visitors](https://visitor-badge.laobi.icu/badge?page_id=IgorKha.Grafana-Mikrotik)
![example branch parameter](https://github.com/IgorKha/Grafana-Mikrotik/actions/workflows/action.yml/badge.svg?branch=master)
![mikrotikOS](https://img.shields.io/badge/Mikrotik_ROS-v6.49-blue)
![Grafana](https://img.shields.io/badge/Grafana-v8.2.1-orange?logo=grafana)
![Prometheus](https://img.shields.io/badge/Prometheus-v2.30.3-red?logo=prometheus)
![mikrotikOS](https://img.shields.io/badge/Mikrotik_ROS-v7.4-blue)
![Grafana](https://img.shields.io/badge/Grafana-v9.0.5-orange?logo=grafana)
![Prometheus](https://img.shields.io/badge/Prometheus-v2.37.0-red?logo=prometheus)
![snmp_exporter](https://img.shields.io/badge/snmp__exporter-v0.20.0-red?logo=prometheus)
[![Donate using Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/~1772367/donate)
-----------
---
## 🐳 Deploy with docker-compose
### Deploy with bash script
```console
curl -fsSL https://raw.githubusercontent.com/IgorKha/Grafana-Mikrotik/master/run.sh | bash -s -- --config
git clone https://github.com/IgorKha/Grafana-Mikrotik.git
cd ./Grafana-Mikrotik
bash ./run.sh --config
```
```console
@ -24,7 +28,7 @@ curl -fsSL https://raw.githubusercontent.com/IgorKha/Grafana-Mikrotik/master/run
--config: change the user and password to grafana and specify the mikrotik IP address
stop: stop docker containers
--stop: stop docker containers
--help
```
@ -32,7 +36,7 @@ curl -fsSL https://raw.githubusercontent.com/IgorKha/Grafana-Mikrotik/master/run
For example:
```console
sh run.sh --config
bash run.sh --config
```
[![asciicast](https://asciinema.org/a/nOhuc7LvI6bRWbg7dcvqFQ4Kc.png)](https://asciinema.org/a/nOhuc7LvI6bRWbg7dcvqFQ4Kc)
@ -55,7 +59,7 @@ docker-compose up -d
If you want to change the credentials, then edit the ".env" file
-----------
---
## Manual deploy
@ -82,9 +86,9 @@ If you want to change the credentials, then edit the ".env" file
3.Add dashboard <https://grafana.com/grafana/dashboards/14420>
-----------
---
### Docker snmp_exporter
### Docker snmp_exporter (deprecated)
[![Docker Pulls](https://img.shields.io/docker/pulls/mashinkopochinko/snmp_exporter_mikrotik?logo=docker)](https://hub.docker.com/repository/docker/mashinkopochinko/snmp_exporter_mikrotik)
@ -94,5 +98,5 @@ If you want to change the credentials, then edit the ".env" file
sudo docker run -d -p 9116:9116 mashinkopochinko/snmp_exporter_mikrotik:latest
```
-----------
---
![img1](/readme/screen.png)

View file

@ -2,25 +2,23 @@ version: '3.9'
services:
grafana:
image: grafana/grafana:8.2.1
image: grafana/grafana:9.0.5
env_file:
- .grafana
container_name: mk_grafana
restart: always
volumes:
- ./grafana/provisioning/:/etc/grafana/provisioning/
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=${GF_ADMIN_USER}
- GF_SECURITY_ADMIN_PASSWORD=${GF_ADMIN_PASSWORD}
- GF_USERS_ALLOW_SIGN_UP=false
prometheus:
image: prom/prometheus
env_file:
- .prometheus
user: ${CURRENT_USER}
container_name: mk_prometheus
restart: always
environment:
- MIKROTIK_IP=${MIKROTIK_IP}
volumes:
- ./prometheus/:/etc/prometheus
- ./prometheus/data/:/prometheus
@ -28,9 +26,11 @@ services:
- "9090:9090"
snmp_exporter:
image: mashinkopochinko/snmp_exporter_mikrotik
image: prom/snmp-exporter
container_name: mk_snmp_exporter
restart: always
volumes:
- ./snmp/:/etc/snmp_exporter/
ports:
- "9116:9116"
depends_on:

File diff suppressed because it is too large Load diff

View file

@ -28,14 +28,15 @@ scrape_configs:
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
scrape_timeout: 5s
scrape_interval: 10s
scrape_timeout: 10s
tls_config:
insecure_skip_verify: true
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
#static_configs:
#- targets: ['localhost:9090']
- job_name: Mikrotik
static_configs:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 287 KiB

Before After
Before After

38
run.sh
View file

@ -4,10 +4,10 @@
# You can also pass some arguments to script to set some these options:
#
# --config: change the user and password to grafana and specify the mikrotik IP address
# stop: stop docker containers
# --stop: stop docker containers
#
# For example:
# sh run.sh --config
# bash run.sh --config
#
############################################################################
@ -15,6 +15,8 @@ set -e
REPO=Grafana-Mikrotik
ENV_FILE=${ENV_FILE:-.env}
ENV_FILE_GF=${ENV_FILE_GF:-.grafana}
ENV_FILE_PROMETHEUS=${ENV_FILE_PROMETHEU:-.prometheus}
#? Colors
RED='\033[31m'
@ -94,7 +96,7 @@ clone_git() {
router_ip() {
if [[ "${CONFIG}" = yes ]]; then
IP=$(grep -R 'MIKROTIK_IP' "${ENV_FILE}" | cut -d= -f2)
IP=$(grep -R 'MIKROTIK_IP' "${ENV_FILE_PROMETHEUS}" 2>&1 | cut -d= -f2)
echo -e "\n${BLUE}===================================="
echo -e "\n${BOLD}Prometheus${RESET}\n"
if ask "Change target mikrotik IP address ? (current ${IP})" Y; then
@ -102,12 +104,12 @@ router_ip() {
if [ -d "./${REPO}" ]; then
sed -ri -e '/mikrotik_ip/s/(- ).*( #.*)/\1'"${IP}"'\2/g' \
${REPO}/prometheus/prometheus.yml
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"$IP"'/g' "${ENV_FILE}"
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"$IP"'/g' "${ENV_FILE_PROMETHEUS}"
echo -e "\n${GREEN}... Prometheus target IP changed to ${IP}"
else
sed -ri -e '/mikrotik_ip/s/(- ).*( #.*)/\1'"${IP}"'\2/g' \
./prometheus/prometheus.yml
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"${IP}"'/g' "${ENV_FILE}"
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"${IP}"'/g' "${ENV_FILE_PROMETHEUS}"
echo -e "\n${GREEN}... Prometheus target IP changed to ${IP}"
fi
return
@ -145,8 +147,8 @@ grafana_credentials() {
read -rp 'Enter grafana Username: ' GF_USER
read -rsp 'Enter grafana Password: ' GF_PASSWD
sed -ri -e 's/^(GF_ADMIN_USER=)(.*)$/\1'"${GF_USER}"'/g' "${ENV_FILE}"
sed -ri -e 's/^(GF_ADMIN_PASSWORD=)(.*)$/\1'"${GF_PASSWD}"'/g' "${ENV_FILE}"
sed -ri -e 's/^(GF_SECURITY_ADMIN_USER=)(.*)$/\1'"${GF_USER}"'/g' "${ENV_FILE_GF}"
sed -ri -e 's/^(GF_SECURITY_ADMIN_PASSWORD=)(.*)$/\1'"${GF_PASSWD}"'/g' "${ENV_FILE_GF}"
else
echo -e "Default Grafana:
User: ${YELLOW}admin${RESET}
@ -156,19 +158,19 @@ grafana_credentials() {
fi
}
docker() {
docker-cmd() {
if [[ "${STOP}" = yes ]]; then
if [ -d "./${REPO}" ]; then
cd ${REPO} && docker-compose down
cd ${REPO} && docker compose down
else
docker-compose down
docker compose down
fi
else
if [[ -d "./${REPO}" ]]; then
cd ${REPO} && docker-compose up -d
cd ${REPO} && docker compose up -d
print_success
else
docker-compose up -d
docker compose up -d
print_success
fi
fi
@ -187,7 +189,7 @@ main() {
case $1 in
--help) HELP=yes ;;
--config) CONFIG=yes ;;
stop) STOP=yes ;;
--stop) STOP=yes ;;
esac
shift
done
@ -195,14 +197,18 @@ main() {
help
command_exists git
command_exists docker-compose
command_exists docker
#? init
if [[ -d "./${REPO}" ]]; then
ENV_FILE=${REPO}/.env
ENV_FILE_GF=${REPO}/.grafana
ENV_FILE_PROMETHEUS=${REPO}/.prometheus
elif [[ ! -e ${ENV_FILE} ]]; then
clone_git
ENV_FILE=${REPO}/.env ;
ENV_FILE=${REPO}/.env
ENV_FILE_GF=${REPO}/.grafana
ENV_FILE_PROMETHEUS=${REPO}/.prometheus
fi
router_ip
@ -212,7 +218,7 @@ main() {
# Change UID:GID prometheus container to current user
sed -ri -e 's/^(CURRENT_USER=)(.*)$/\1'"$(id -u)\:$(id -g)"'/g' "${ENV_FILE}"
docker
docker-cmd
}
main "$@"

View file

@ -1,4 +1,12 @@
# WARNING: This file was auto-generated using snmp_exporter generator, manual changes will be lost.
auths:
public_v2:
community: public
security_level: noAuthNoPriv
auth_protocol: MD5
priv_protocol: DES
version: 2
modules:
mikrotik:
walk:
- 1.3.6.1.2.1.2