Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken metrics -> cannot fetch TP-Link router metrics #8

Open
Majroch opened this issue May 3, 2023 · 0 comments
Open

Broken metrics -> cannot fetch TP-Link router metrics #8

Majroch opened this issue May 3, 2023 · 0 comments

Comments

@Majroch
Copy link

Majroch commented May 3, 2023

Hi, I wanted to try this project out. I have 2 routers from tp-link in my home.

I created docker-compose file, like:

---
version: "3"
services:
  tplink_exporter:
    restart: unless-stopped
    build:
      context: ./
      dockerfile: Dockerfile
    ports:
     - "9300:9300"
    volumes:
     - "./known_macs:/etc/known_macs"
    user: '1000:1000'

When building this container, with command:

$ docker compose build --no-cache

I got:

 => [internal] load .dockerignore                                                                                                                                                     0.0s
 => => transferring context: 2B                                                                                                                                                       0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                  0.0s
 => => transferring dockerfile: 545B                                                                                                                                                  0.0s
 => [internal] load metadata for docker.io/library/golang:alpine                                                                                                                      0.0s
 => [builder 1/5] FROM docker.io/library/golang:alpine                                                                                                                                0.0s
 => [internal] load build context                                                                                                                                                     0.0s
 => => transferring context: 6.34kB                                                                                                                                                   0.0s
 => CACHED [builder 2/5] WORKDIR /go/src/github.com/maesoser/tplink_exporter                                                                                                          0.0s
 => [builder 3/5] COPY . .                                                                                                                                                            0.1s
 => ERROR [builder 4/5] RUN adduser -D tplink && go mod tidy                                                                                                                          1.8s
------                                                                                                                                                                                     
 > [builder 4/5] RUN adduser -D tplink && go mod tidy:                                                                                                                                     
#0 0.987 go: finding module for package github.com/prometheus/client_golang/prometheus/promhttp                                                                                            
#0 0.987 go: finding module for package github.com/maesoser/tplink_exporter/tplink                                                                                                         
#0 0.987 go: finding module for package github.com/maesoser/tplink_exporter/macdb                                                                                                          
#0 0.987 go: finding module for package github.com/prometheus/client_golang/prometheus                                                                                                     
#0 1.619 go: downloading github.com/prometheus/client_golang v1.15.1
#0 1.655 go: downloading github.com/maesoser/tplink_exporter v0.0.0-20220702113403-9a98236f2f3d
#0 1.764 go: found github.com/maesoser/tplink_exporter/macdb in github.com/maesoser/tplink_exporter v0.0.0-20220702113403-9a98236f2f3d
#0 1.764 go: found github.com/maesoser/tplink_exporter/tplink in github.com/maesoser/tplink_exporter v0.0.0-20220702113403-9a98236f2f3d
#0 1.764 go: found github.com/prometheus/client_golang/prometheus in github.com/prometheus/client_golang v1.15.1
#0 1.764 go: found github.com/prometheus/client_golang/prometheus/promhttp in github.com/prometheus/client_golang v1.15.1
#0 1.764 go: main imports
#0 1.764        github.com/maesoser/tplink_exporter/macdb: github.com/maesoser/[email protected]: parsing go.mod:
#0 1.764        module declares its path as: main
#0 1.764                but was required as: github.com/maesoser/tplink_exporter
------
WARN[0000] buildx: git was not found in the system. Current commit information was not captured by the build 
failed to solve: process "/bin/sh -c adduser -D tplink && go mod tidy" did not complete successfully: exit code: 1

I've found a solution for this, over at this stackoverflow thread, and fixed it with simple one line in go.mod file:

replace github.com/maesoser/tplink_exporter => ./

After that, image was builded successfully. But when i want to try getting those metrics, like:

$ curl 172.20.0.2:9300/metrics 2>/dev/null

I get some basic metrics, without tplink_* or anything which would allow me to get router statistics.

cURL output:

# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 5.4965e-05
go_gc_duration_seconds{quantile="0.25"} 6.0972e-05
go_gc_duration_seconds{quantile="0.5"} 6.5232e-05
go_gc_duration_seconds{quantile="0.75"} 7.0261e-05
go_gc_duration_seconds{quantile="1"} 7.9619e-05
go_gc_duration_seconds_sum 0.000331049
go_gc_duration_seconds_count 5
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 6
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.20.4"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 2.659376e+06
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 6.5326e+06
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 4205
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 55938
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 7.68268e+06
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 2.659376e+06
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 3.6864e+06
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 4.112384e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 27888
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 3.448832e+06
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 7.798784e+06
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 1.683131348111072e+09
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 0
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 83826
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 14400
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 15600
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 131840
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 146880
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 5.557136e+06
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 1.848955e+06
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 589824
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 589824
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 1.8086928e+07
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 9
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.11
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 10
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.4422016e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.68313096412e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 7.37251328e+08
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 2
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0

Tried setting my .env file, like:

TPLINK_ROUTER_ADDR=XXX.XXX.XXX.XXX
TPLINK_ROUTER_PASSWD=hackme

But still no luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant