virtua-network / smartos_exporter

Prometheus exporter for SmartOS
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

panic with parseNicstatOutput #26

Open MrApe opened 5 years ago

MrApe commented 5 years ago

I'm using version 20180708.smartos-x86_64. The exporter start fine but querying the /metrics endpoint causes a panic with the following trace:

: ./smartos_exporter-20180708.smartos-x86_64
INFO[0000] Starting smartos_exporter (version=, branch=, revision=)  source="main.go:63"
INFO[0000] Listening on :9100                            source="main.go:101"
ERRO[0002] error on executing nicstat: exit status 1     source="nicstat.go:58"
panic: runtime error: slice bounds out of range

goroutine 54 [running]:
github.com/virtua-network/smartos_exporter/collector.(*GZMLAGUsageCollector).parseNicstatOutput(0xc42001ee70, 0x0, 0x0, 0x200, 0x0)
        /root/go/src/github.com/virtua-network/smartos_exporter/collector/nicstat.go:69 +0x41a
github.com/virtua-network/smartos_exporter/collector.(*GZMLAGUsageCollector).nicstat(0xc42001ee70)
        /root/go/src/github.com/virtua-network/smartos_exporter/collector/nicstat.go:60 +0x15b
github.com/virtua-network/smartos_exporter/collector.(*GZMLAGUsageCollector).Collect(0xc42001ee70, 0xc420030960)
        /root/go/src/github.com/virtua-network/smartos_exporter/collector/nicstat.go:48 +0x2b
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()
        /root/go/src/github.com/prometheus/client_golang/prometheus/registry.go:401 +0x5c
created by github.com/prometheus/client_golang/prometheus.(*Registry).Gather
        /root/go/src/github.com/prometheus/client_golang/prometheus/registry.go:454 +0x816

Some system info:

{
  "Live Image": "20180913T002056Z",
  "System Type": "SunOS",
  "Boot Time": "1537893096",
  "SDC Version": "7.0",
  "Manufacturer": "HP",
  "Product": "ProLiant DL380 G7",
[...]
  "CPU Type": "Intel(R) Xeon(R) CPU E5645 @ 2.40GHz",
  "CPU Virtualization": "vmx",
  "CPU Physical Cores": 2,
[...]
  "CPU Total Cores": 12,
  "MiB of Memory": "73717",
[...]
  "Network Interfaces": {
    "bnx2": {"MAC Address": "[...]", "ip4addr": "[...]", "Link Status": "up", "NIC Names": ["admin"]},
    "bnx0": {"MAC Address": "[...]", "ip4addr": "", "Link Status": "down", "NIC Names": []},
    "bnx1": {"MAC Address": "[...]", "ip4addr": "", "Link Status": "down", "NIC Names": []},
    "bnx3": {"MAC Address": "[...]", "ip4addr": "", "Link Status": "up", "NIC Names": ["backbone"]}
  },
  "Virtual Network Interfaces": {
    "backbone0": {"MAC Address": "[...]", "ip4addr": "[...]", "Link Status": "up", "Host Interface": "bnx3", "VLAN": "0"}
  },
  "Link Aggregations": {
  }
}
whymidnight commented 3 years ago

@MrApe,

On line 56 in nicstat.go, you'll want to change aggr0 to whatever interface you'll want to monitor.

Just started looking at the code so not sure atm how to incorporate multiple interfaces.

Best