prometheus-moto-exporter icon indicating copy to clipboard operation
prometheus-moto-exporter copied to clipboard

Parse error in upstream.Parse

Open iamseth opened this issue 2 years ago • 2 comments

When I build and run locally, I'm getting a parsing error for upstream. It looks like in my case, I'm getting a leading space "parse frequency: strconv.ParseFloat: parsing \" 0.0\": invalid syntax" row="[1 Locked OFDMA 1 0 0.0 0.0 ]".

I was able to fix this locally by injecting a call to strings.TrimSpace between the calls to strconv.ParseInt and strconv.ParseFloat

I can create a PR if you'd like. The README mentions to discuss first so here I am :).

Here's how to repro.

oxygen ~/Documents/dev/personal/prometheus-moto-exporter > git ll -1
68895b5 2023-02-18 (HEAD -> main, origin/main, origin/HEAD) chore(deps): bump golang.org/x/net from 0.4.0 to 0.7.0 [dependabot[bot]]

oxygen ~/Documents/dev/personal/prometheus-moto-exporter > go build ./cmd/prometheus-moto-exporter

oxygen ~/Documents/dev/personal/prometheus-moto-exporter > ./prometheus-moto-exporter --password $MOTO_PW --debug
DEBU[0000] configured for HNAP metrics                   endpoint="https://192.168.100.1/HNAP1/" username=admin
INFO[0000] starting server on 127.0.0.1:9731             context=server
INFO[0000] collecting                                    context=collect
DEBU[0000] requesting challenge                          action=login
DEBU[0000] accepting challenge                           action=login
DEBU[0000] submitting response                           action=login
DEBU[0000] response sent                                 action="http://purenetworks.com/HNAP1/Login" action.call=login status=200
ERRO[0008] could not parse data                          error="parse frequency: strconv.ParseFloat: parsing \" 0.0\": invalid syntax" row="[1 Locked OFDMA 1 0  0.0  0.0 ]"
INFO[0008] finished collecting                           context=collect
ERRO[0008] collection error                              context=collect error="cannot parse data: parse frequency: strconv.ParseFloat: parsing \" 0.0\": invalid syntax"
^CINFO[0010] SIGINT: shutting down server
INFO[0010] shutting down server                          context=server
INFO[0010] server shutdown                               context=server
INFO[0010] done

iamseth avatar Feb 22 '23 03:02 iamseth