Skip to content

Commit

Permalink
Don't walk the entire interface table to just retrieve one field (inf…
Browse files Browse the repository at this point in the history
  • Loading branch information
Hipska authored Mar 29, 2021
1 parent 871447b commit ffe92a7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugins/processors/ifname/ifname.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ func (d *IfName) Start(acc telegraf.Accumulator) error {
return fmt.Errorf("parsing SNMP client config: %w", err)
}

d.ifTable, err = d.makeTable("IF-MIB::ifTable")
d.ifTable, err = d.makeTable("IF-MIB::ifDescr")
if err != nil {
return fmt.Errorf("looking up ifTable in local MIB: %w", err)
return fmt.Errorf("looking up ifDescr in local MIB: %w", err)
}
d.ifXTable, err = d.makeTable("IF-MIB::ifXTable")
d.ifXTable, err = d.makeTable("IF-MIB::ifName")
if err != nil {
return fmt.Errorf("looking up ifXTable in local MIB: %w", err)
return fmt.Errorf("looking up ifName in local MIB: %w", err)
}

fn := func(m telegraf.Metric) []telegraf.Metric {
Expand Down Expand Up @@ -347,11 +347,13 @@ func init() {
})
}

func makeTableNoMock(tableName string) (*si.Table, error) {
func makeTableNoMock(fieldName string) (*si.Table, error) {
var err error
tab := si.Table{
Oid: tableName,
IndexAsTag: true,
Fields: []si.Field{
{Oid: fieldName},
},
}

err = tab.Init()
Expand Down

0 comments on commit ffe92a7

Please sign in to comment.