- $v{'type_instance'} = $key;
- for ($key = 0; $key <= $#if_instances; ++$key) {
- $v{'type'} = $if_instances[$key];
- $v{'values'} = [ $counters[$key], $counters[$key + 8] ];
- plugin_dispatch_values(\%v);
+ my ($iface, %rx, %tx);
+
+ # read /proc/net/dev fields
+ ($iface, @rx{@rx_fields}, @tx{@tx_fields}) = split /[: ]+/, $line;
+
+ # Skip this interface if it is in the ignored list
+ next if grep { $iface eq $_ } @ignored_interfaces;
+
+ for my $instance (qw(if_octets if_packets if_errors)) {
+ plugin_dispatch_values({
+ 'plugin' => 'interface',
+ 'plugin_instance' => $iface,
+ 'type' => $instance,
+ 'values' => [ $rx{$instance}, $tx{$instance} ],
+ %v,
+ });
+ }