mirror of
https://github.com/IgorKha/Grafana-Mikrotik.git
synced 2025-12-10 12:29:29 +00:00
Compare commits
No commits in common. "master" and "8.2.1.01" have entirely different histories.
12 changed files with 5310 additions and 8443 deletions
5
.env
5
.env
|
|
@ -1 +1,4 @@
|
|||
CURRENT_USER=1000:1000
|
||||
GF_ADMIN_USER=admin
|
||||
GF_ADMIN_PASSWORD=mikrotik
|
||||
CURRENT_USER=root
|
||||
MIKROTIK_IP=192.168.88.1
|
||||
13
.github/workflows/action.yml
vendored
13
.github/workflows/action.yml
vendored
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
with:
|
||||
path: "run.sh"
|
||||
severity: "warning, error"
|
||||
|
||||
|
||||
test:
|
||||
name: test
|
||||
needs: lint
|
||||
|
|
@ -22,12 +22,13 @@ jobs:
|
|||
steps:
|
||||
- name: deploy with sh script
|
||||
run: curl -fsSL https://raw.githubusercontent.com/IgorKha/Grafana-Mikrotik/master/run.sh | bash -s --
|
||||
|
||||
|
||||
- name: Test Grafana
|
||||
run: sleep 10 && curl -GLsS --retry 5 --retry-connrefused --retry-delay 2 'http://localhost:3000/api/health'
|
||||
run: sleep 5 && curl -ILsS --retry 5 --retry-delay 2 "http://localhost:3000/login"
|
||||
|
||||
- name: Test Prometheus
|
||||
run: curl -GLsS --retry 5 --retry-delay 2 "http://localhost:9090/-/ready"
|
||||
|
||||
run: curl -ILsS --retry 5 --retry-delay 2 "http://localhost:9090"
|
||||
|
||||
- name: Test snmp_exporter
|
||||
run: curl -ILsS --retry 5 --retry-delay 2 "http://localhost:9116"
|
||||
run: curl -ILsS --retry 5 --retry-delay 2 "http://localhost:9116"
|
||||
|
||||
3
.grafana
3
.grafana
|
|
@ -1,3 +0,0 @@
|
|||
GF_SECURITY_ADMIN_USER=admin
|
||||
GF_SECURITY_ADMIN_PASSWORD=mikrotik
|
||||
GF_USERS_ALLOW_SIGN_UP=false
|
||||
|
|
@ -1 +0,0 @@
|
|||
MIKROTIK_IP=192.168.88.1
|
||||
File diff suppressed because it is too large
Load diff
30
README.md
30
README.md
|
|
@ -1,26 +1,22 @@
|
|||
# Grafana-Mikrotik
|
||||
|
||||

|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
[](https://liberapay.com/~1772367/donate)
|
||||
|
||||
---
|
||||
-----------
|
||||
|
||||
## 🐳 Deploy with docker-compose
|
||||
|
||||
### Deploy with bash script
|
||||
|
||||
```console
|
||||
git clone https://github.com/IgorKha/Grafana-Mikrotik.git
|
||||
cd ./Grafana-Mikrotik
|
||||
bash ./run.sh --config
|
||||
curl -fsSL https://raw.githubusercontent.com/IgorKha/Grafana-Mikrotik/master/run.sh | bash -s -- --config
|
||||
```
|
||||
|
||||
```console
|
||||
|
|
@ -28,7 +24,7 @@ bash ./run.sh --config
|
|||
|
||||
--config: change the user and password to grafana and specify the mikrotik IP address
|
||||
|
||||
--stop: stop docker containers
|
||||
stop: stop docker containers
|
||||
|
||||
--help
|
||||
```
|
||||
|
|
@ -36,7 +32,7 @@ bash ./run.sh --config
|
|||
For example:
|
||||
|
||||
```console
|
||||
bash run.sh --config
|
||||
sh run.sh --config
|
||||
```
|
||||
|
||||
[](https://asciinema.org/a/nOhuc7LvI6bRWbg7dcvqFQ4Kc)
|
||||
|
|
@ -53,13 +49,13 @@ docker-compose up -d
|
|||
|
||||
3.Open [localhost:3000](http://localhost:3000)
|
||||
|
||||
* Grafana login: `admin`
|
||||
* Grafana login: `admin`
|
||||
|
||||
* Password: `mikrotik`
|
||||
* Password: `mikrotik`
|
||||
|
||||
If you want to change the credentials, then edit the ".env" file
|
||||
|
||||
---
|
||||
-----------
|
||||
|
||||
## Manual deploy
|
||||
|
||||
|
|
@ -86,9 +82,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 (deprecated)
|
||||
### Docker snmp_exporter
|
||||
|
||||
[](https://hub.docker.com/repository/docker/mashinkopochinko/snmp_exporter_mikrotik)
|
||||
|
||||
|
|
@ -98,5 +94,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,23 +2,25 @@ version: '3.9'
|
|||
|
||||
services:
|
||||
grafana:
|
||||
image: grafana/grafana:9.0.5
|
||||
env_file:
|
||||
- .grafana
|
||||
image: grafana/grafana:8.2.1
|
||||
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
|
||||
|
|
@ -26,12 +28,10 @@ services:
|
|||
- "9090:9090"
|
||||
|
||||
snmp_exporter:
|
||||
image: prom/snmp-exporter
|
||||
image: mashinkopochinko/snmp_exporter_mikrotik
|
||||
container_name: mk_snmp_exporter
|
||||
restart: always
|
||||
volumes:
|
||||
- ./snmp/:/etc/snmp_exporter/
|
||||
ports:
|
||||
- "9116:9116"
|
||||
depends_on:
|
||||
- prometheus
|
||||
- prometheus
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -28,15 +28,14 @@ scrape_configs:
|
|||
- job_name: 'prometheus'
|
||||
|
||||
# Override the global default and scrape targets from this job every 5 seconds.
|
||||
scrape_interval: 10s
|
||||
scrape_timeout: 10s
|
||||
tls_config:
|
||||
insecure_skip_verify: true
|
||||
scrape_interval: 5s
|
||||
scrape_timeout: 5s
|
||||
|
||||
# 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: 287 KiB After Width: | Height: | Size: 246 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:
|
||||
# bash run.sh --config
|
||||
# sh run.sh --config
|
||||
#
|
||||
############################################################################
|
||||
|
||||
|
|
@ -15,8 +15,6 @@ 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'
|
||||
|
|
@ -96,7 +94,7 @@ clone_git() {
|
|||
|
||||
router_ip() {
|
||||
if [[ "${CONFIG}" = yes ]]; then
|
||||
IP=$(grep -R 'MIKROTIK_IP' "${ENV_FILE_PROMETHEUS}" 2>&1 | cut -d= -f2)
|
||||
IP=$(grep -R 'MIKROTIK_IP' "${ENV_FILE}" | 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
|
||||
|
|
@ -104,12 +102,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_PROMETHEUS}"
|
||||
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"$IP"'/g' "${ENV_FILE}"
|
||||
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_PROMETHEUS}"
|
||||
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"${IP}"'/g' "${ENV_FILE}"
|
||||
echo -e "\n${GREEN}... Prometheus target IP changed to ${IP}"
|
||||
fi
|
||||
return
|
||||
|
|
@ -147,8 +145,8 @@ grafana_credentials() {
|
|||
read -rp 'Enter grafana Username: ' GF_USER
|
||||
read -rsp 'Enter grafana Password: ' GF_PASSWD
|
||||
|
||||
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}"
|
||||
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}"
|
||||
else
|
||||
echo -e "Default Grafana:
|
||||
User: ${YELLOW}admin${RESET}
|
||||
|
|
@ -158,19 +156,19 @@ grafana_credentials() {
|
|||
fi
|
||||
}
|
||||
|
||||
docker-cmd() {
|
||||
docker() {
|
||||
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
|
||||
|
|
@ -189,7 +187,7 @@ main() {
|
|||
case $1 in
|
||||
--help) HELP=yes ;;
|
||||
--config) CONFIG=yes ;;
|
||||
--stop) STOP=yes ;;
|
||||
stop) STOP=yes ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
|
@ -197,18 +195,14 @@ main() {
|
|||
help
|
||||
|
||||
command_exists git
|
||||
command_exists docker
|
||||
command_exists docker-compose
|
||||
|
||||
#? 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_GF=${REPO}/.grafana
|
||||
ENV_FILE_PROMETHEUS=${REPO}/.prometheus
|
||||
ENV_FILE=${REPO}/.env ;
|
||||
fi
|
||||
|
||||
router_ip
|
||||
|
|
@ -218,7 +212,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-cmd
|
||||
docker
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
|
|||
8766
snmp/snmp.yml
8766
snmp/snmp.yml
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue