Skip to content

Commit

Permalink
Merge pull request #1141 from bosun-monitor/totalBytes
Browse files Browse the repository at this point in the history
Scollector: calculate os.net.bytes.total metric.
  • Loading branch information
captncraig committed Jul 6, 2015
2 parents e69976d + 79add32 commit 8eabd7d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/scollector/collectors/snmp_ifaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ func SNMPIfaces(cfg conf.SNMP) {
}

func switch_bond(metric, iname string) string {
if strings.Contains(iname, "port-channel") {
if isBondInterface(iname) {
return "os.net.bond" + strings.TrimPrefix(metric, "os.net")
}
return metric
}

func isBondInterface(iname string) bool {
return strings.Contains(iname, "port-channel")
}

func c_snmp_ifaces(community, host string) (opentsdb.MultiDataPoint, error) {
n, err := snmp_subtree(host, community, ifName)
if err != nil || len(n) == 0 {
Expand Down Expand Up @@ -79,16 +83,24 @@ func c_snmp_ifaces(community, host string) (opentsdb.MultiDataPoint, error) {
if err != nil {
return err
}
var sum int64
for k, v := range m {
tags := opentsdb.TagSet{
"host": host,
"direction": dir,
"iface": fmt.Sprintf("%d", k),
"iname": names[k],
}
if iVal, ok := v.(int64); ok && !isBondInterface(names[k]) {
sum += iVal
}
Add(&md, switch_bond(metric, names[k]), v, tags, metadata.Unknown, metadata.None, "")
metadata.AddMeta("", tags, "alias", aliases[k], false)
}
if metric == osNetBytes {
tags := opentsdb.TagSet{"host": host, "direction": dir}
Add(&md, osNetBytes+".total", sum, tags, metadata.Counter, metadata.Bytes, "")
}
return nil
}
oids := []snmpAdd{
Expand Down

0 comments on commit 8eabd7d

Please sign in to comment.