shackerd / freebox-exporter-rs

Unofficial Free S.A.S. ISP Freebox API exporter for Prometheus
MIT License
1 stars 1 forks source link

0.0.3 crashes on lan browser #35

Closed ottobaer closed 3 months ago

ottobaer commented 3 months ago

Hi,

I just wanted to try the new version, but it seems it's crashing on the lan metrics.

I think this is because my freebox is in bridge mode so the lan interfaces are missing / not accessible.


INFO [freebox_exporter_rs] using api url: https://mafreebox.freebox.fr/api/
INFO [prometheus_exporter] exporting metrics to http://0.0.0.0:9102/metrics
thread 'main' panicked at src/mappers/lanbrowser.rs:371:72:
called `Result::unwrap()` on an `Err` value: Error("missing field `result`", line: 1, column: 16)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
   1: core::panicking::panic_fmt
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/result.rs:1649:5
   3: freebox_exporter_rs::mappers::lanbrowser::LanBrowserMetricMap::get_ifaces::{{closure}}
   4: <freebox_exporter_rs::mappers::lanbrowser::LanBrowserMetricMap as freebox_exporter_rs::mappers::MetricMap>::init::{{closure}}
   5: freebox_exporter_rs::serve::{{closure}}
   6: freebox_exporter_rs::main::{{closure}}
   7: tokio::runtime::park::CachedParkThread::block_on
   8: freebox_exporter_rs::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
shackerd commented 3 months ago

Hi @ottobaer, thanks for the feedback, sorry for the inconveniance. You are right, bridge mode is indeed the cause of the issue. Due to the lack of documentation of the API behavior, I was not able to anticipate it. However you can disable lan_browser in config.toml. I will add a check for freebox bridge mode before activating this API mapping and future ones.

Also their is another bug which leads to application crash when API result property is null and status is success.