Skip to content

Commit

Permalink
T5702: SNMP add interface-mib max-interfaces-number and prefix
Browse files Browse the repository at this point in the history
- Allow to configure only required interface prefixes

  set service snmp mib interface 'eth'
  set service snmp mib interface 'bond'

 include_ifmib_iface_prefix eth bond

Sets the interface name prefixes to include in the IF-MIB data collection.
For servers with a large number of interfaces (ppp, dummy, bridge, etc)
the IF-MIB processing will take a large chunk of CPU for ioctl calls.
A set of space separated interface name prefixes will reduce the CPU
load for IF-MIB processing. For example, configuring
"include_ifmib_iface_prefix eth dummy lo" will include only interfaces
with these prefixes and ignore all others for IF-MIB processing.

- Allow to configure maximum interface number

  set service snmp mib interface-max '100'

  ifmib_max_num_ifaces NUM

Sets the maximum number of interfaces included in IF-MIB data collection.
For servers with a large number of interfaces (ppp, dummy, bridge, etc)
the IF-MIB processing will take a large chunk of CPU for ioctl calls
(on Linux). Setting a reasonable maximum for the CPU used will
reduce the CPU load for IF-MIB processing.  For example, configuring
"ifmib_max_num_ifaces 500" will include only the first 500 interfaces
based on ifindex and ignore all others for IF-MIB processing.
  • Loading branch information
sever-sever committed Nov 4, 2023
1 parent d8a7197 commit c191c4d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions data/templates/snmp/etc.snmpd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ SysDescr {{ description }}
{% endif %}
agentaddress unix:/run/snmpd.socket{{ ',' ~ options | join(',') if options is vyos_defined }}

{% if mib is vyos_defined %}
# Interface MIB limits
{% if mib.interface_max is vyos_defined %}
ifmib_max_num_ifaces {{ mib.interface_max }}
{% endif %}
{% if mib.interface is vyos_defined %}
include_ifmib_iface_prefix {{ mib.interface | join(' ') }}
{% endif %}
{% endif %}

# SNMP communities
{% if community is vyos_defined %}
{% for comm, comm_config in community.items() %}
Expand Down
33 changes: 33 additions & 0 deletions interface-definitions/snmp.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,39 @@
</properties>
</leafNode>
#include <include/generic-description.xml.i>
<node name="mib">
<properties>
<help>Management information base (MIB)</help>
</properties>
<children>
<leafNode name="interface-max">
<properties>
<help>Sets the maximum number of interfaces included in IF-MIB data collection</help>
<valueHelp>
<format>u32:1-4294967295</format>
<description>Sets the maximum number of interfaces included in IF-MIB data collection</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-4294967295"/>
</constraint>
</properties>
</leafNode>
<leafNode name="interface">
<properties>
<help>Sets the interface name prefix to include in the IF-MIB data collection</help>
<valueHelp>
<format>txt</format>
<description>Sets the interface name prefix to include in the IF-MIB data collection</description>
</valueHelp>
<constraint>
<regex>(\!?)(bond|br|dum|en|ersp|eth|gnv|ifb|lan|l2tp|l2tpeth|macsec|peth|ppp|pppoe|pptp|sstp|tun|veth|vti|vtun|vxlan|wg|wlan|wwan)([0-9]?)(\*?)(.+)?|(\!?)lo</regex>
<validator name="vrf-name"/>
</constraint>
<multi/>
</properties>
</leafNode>
</children>
</node>
<tagNode name="listen-address">
<properties>
<help>IP address to listen for incoming SNMP requests</help>
Expand Down

0 comments on commit c191c4d

Please sign in to comment.