mirror of
https://github.com/IgorKha/Grafana-Mikrotik.git
synced 2025-12-06 10:29:28 +00:00
Compare commits
14 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da35426cfd | ||
|
|
2550ba1fe0 | ||
|
|
f741901f03 | ||
|
|
aa802b1c36 | ||
|
|
1f8ddb8254 | ||
|
|
8dbeac2110 | ||
|
|
0e616af363 | ||
|
|
aafa4316d5 | ||
|
|
f1107cf89f | ||
|
|
5b3213838b | ||
|
|
4ad3af58e0 | ||
|
|
b7a80c3106 | ||
|
|
3adcdd666a | ||
|
|
51ca2896de |
12 changed files with 8443 additions and 5310 deletions
5
.env
5
.env
|
|
@ -1,4 +1 @@
|
|||
GF_ADMIN_USER=admin
|
||||
GF_ADMIN_PASSWORD=mikrotik
|
||||
CURRENT_USER=root
|
||||
MIKROTIK_IP=192.168.88.1
|
||||
CURRENT_USER=1000:1000
|
||||
|
|
|
|||
5
.github/workflows/action.yml
vendored
5
.github/workflows/action.yml
vendored
|
|
@ -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
3
.grafana
Normal 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
1
.prometheus
Normal file
|
|
@ -0,0 +1 @@
|
|||
MIKROTIK_IP=192.168.88.1
|
||||
File diff suppressed because it is too large
Load diff
26
README.md
26
README.md
|
|
@ -1,22 +1,26 @@
|
|||
# Grafana-Mikrotik
|
||||
|
||||

|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
[](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
|
||||
```
|
||||
|
||||
[](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)
|
||||
|
||||
[](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
|
||||
```
|
||||
|
||||
-----------
|
||||
---
|
||||

|
||||
|
|
|
|||
|
|
@ -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
|
|
@ -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 |
38
run.sh
38
run.sh
|
|
@ -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 "$@"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue