Skip to content

Commit

Permalink
Replace TotalBytesSent and TotalBytesReceived (#24)
Browse files Browse the repository at this point in the history
replace both variables through the 64 byte ones
because the variables are formatted as a string there is an additional
change in fritzboxmetrics.go

Co-authored-by: Max Schmitt <max@schmitt.mx>
  • Loading branch information
nachfuellbar and mxschmitt committed Feb 8, 2021
1 parent 4cea6b2 commit 2ae86fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var metrics = []*Metric{
{
Service: "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
Action: "GetAddonInfos",
Result: "TotalBytesReceived",
Result: "X_AVM_DE_TotalBytesReceived64",
Desc: prometheus.NewDesc(
"gateway_wan_bytes_received",
"bytes received on gateway WAN interface",
Expand All @@ -89,7 +89,7 @@ var metrics = []*Metric{
{
Service: "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
Action: "GetAddonInfos",
Result: "TotalBytesSent",
Result: "X_AVM_DE_TotalBytesSent64",
Desc: prometheus.NewDesc(
"gateway_wan_bytes_sent",
"bytes sent on gateway WAN interface",
Expand Down
9 changes: 9 additions & 0 deletions pkg/fritzboxmetrics/fritzboxmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ func (a *Action) parseSoapResponse(r io.Reader) (Result, error) {
}

func convertResult(val string, arg *Argument) (interface{}, error) {
switch arg.StateVariable.Name {
case "X_AVM_DE_TotalBytesSent64", "X_AVM_DE_TotalBytesReceived64":
res, err := strconv.ParseUint(val, 10, 64)
if err != nil {
return nil, errors.Wrap(err, "could not parse uint")
}
return uint64(res), nil
}

switch arg.StateVariable.DataType {
case "string":
return val, nil
Expand Down

0 comments on commit 2ae86fa

Please sign in to comment.