M0r13n / mikrotik_monitoring

Monitor your Mikrotik router with Prometheus and Grafana
MIT License
240 stars 33 forks source link

Not pulling any data #14

Closed rackifiaustin closed 1 year ago

rackifiaustin commented 1 year ago

Hello,

I have a MikroTik CCR2216 (new flagship) and followed your tutorial to a perfect "T".

I have an outside VPS with a static IP pointed to the router IP (I can login over Winbox with the account on a netbook with 5G) so I know that is correct (the hostname, and user/password).

UFW is disabled on my Ubuntu install running just your docker clone.

Only changes I made to your config was:

enabled = True hostname

username password

Nothing else was changed but I just do not receive any data on your dashboard. Any help would be appreciated! The FAQ didn't help in this instance.

CCR2216 is on 7.6

M0r13n commented 1 year ago

Hey @rackifiaustin,

here are some things, that you should try:

Check if the exporter is running

pi@grafana:~/mikrotik_monitoring $ docker-compose ps
           Name                          Command               State                         Ports                       
-------------------------------------------------------------------------------------------------------------------------
grafana                       /run.sh                          Up      3000/tcp                                          
mikrotik_monitoring_mktxp_1   /usr/local/bin/mktxp export      Up      49090/tcp                                         
nginx                         /docker-entrypoint.sh ngin ...   Up      0.0.0.0:443->443/tcp,:::443->443/tcp,             
                                                                       0.0.0.0:80->80/tcp,:::80->80/tcp                  
prometheus                    /bin/prometheus --config.f ...   Up      9090/tcp  

Check the exporter logs

docker-compose logs mktxp

Attach to the exporter container

$ docker container exec -it mikrotik_monitoring_mktxp_1 /bin/sh
/mktxp $ python mktxp/cli/dispatch.py info
/mktxp $ python mktxp/cli/dispatch.py show
/mktxp $ python mktxp/cli/dispatch.py print -en RB3011 -dc

Replace the RB3011 with the name of your device in the configuration that you created (the mktxp.conf file)

M0r13n commented 1 year ago

Also make sure that the exporter can connect to your router. By default Mikrotik writes a warning to the log file if a user connects via the API. The line looks roughly like this:

user prometheus logged in from 10.0.10.209 via api

Did you ensure that the API service is enabled on your router? Dou you use SSL for the API? Is the API reachable (IP and port) from the exporter?

rackifiaustin commented 1 year ago

Hello!

So, I did some things here!

1.) I made a mktxp user and created it under it's own directory.

Now, when I run docker-compose logs mktxp I get this error:

` mktxp_1 | Error updating system entry MKTXP with new system keys ['fetch_routers_in_parallel', 'verbose_mode']: [Errno 13] Permission denied: '/home/mktxp/mktxp/_mktxp.conf'

mktxp_1 | Please update _mktxp.conf to its latest version manually `

M0r13n commented 1 year ago

This permission error is caused by missing write permission for the bind-mounted volume. By default directories are bind-mounted with read and execute permissions - but without write permissions. This a security measure to protect the host system from malformed or malicious containers. Refer to the last part of the FAQ.

You have two options to resolve this issue:

  1. give all users write permission: chmod u+w ./mktxp
  2. make sure that both configuration files contain all necessary keys

I strongly recommend you to choose option 2 due to security reasons. May I ask if you changed the image used for mktxp? This is defined in this line: image: leonmorten/mktxp:latest. I am asking, because the configuration key fetch_routers_in_parallel was just introduced a couple of days ago by myself. I did not update this monitoring stack (the docker files found in this repo) yet. But I always keep the latest version of the image leonmorten/mktxp:latest up to date so that is works with this stack.

Regarding your problem the easiest solution, that I can think of, is the following:

  1. open https://github.com/akpw/mktxp/tree/main/mktxp/cli/config
  2. copy the two files mktxp.conf and _mktxp.conf into your monitoring stack (mikrotik_monitoring/mktxp/)
  3. make sure that you use the most recent version of these config files and also ensure that all keys are present
  4. update all keys to match your local environment
M0r13n commented 1 year ago

I consider this issue as closed.