Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scollector: calculate os.net.bytes.total metric. #1141

Merged
merged 1 commit into from
Jul 6, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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