summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav <v.gletenko@vyos.io>2021-08-10 09:54:19 +0000
committerViacheslav <v.gletenko@vyos.io>2021-08-10 09:54:19 +0000
commitc87d3c277c4a023d42962005676827d69a976a1d (patch)
treea1db517278e5ca25b69f17fb6921a2d99cf7d2c7
parent0b37de6ba97810636ecbf9a84c6df8f5409ae78c (diff)
downloadvyos-1x-c87d3c277c4a023d42962005676827d69a976a1d.tar.gz
vyos-1x-c87d3c277c4a023d42962005676827d69a976a1d.zip
snmp: T3709: Allow enable oid ipCidrRouteTable
-rw-r--r--data/templates/snmp/override.conf.tmpl3
-rw-r--r--interface-definitions/snmp.xml.in20
-rwxr-xr-xsrc/conf_mode/snmp.py6
3 files changed, 27 insertions, 2 deletions
diff --git a/data/templates/snmp/override.conf.tmpl b/data/templates/snmp/override.conf.tmpl
index 90c294ed0..2ac45a89f 100644
--- a/data/templates/snmp/override.conf.tmpl
+++ b/data/templates/snmp/override.conf.tmpl
@@ -1,4 +1,5 @@
{% set vrf_command = 'ip vrf exec ' + vrf + ' ' if vrf is defined else '' %}
+{% set oid_route_table = ' ' if route_table is sameas true else '-I -ipCidrRouteTable,inetCidrRouteTable' %}
[Unit]
StartLimitIntervalSec=0
After=vyos-router.service
@@ -7,7 +8,7 @@ After=vyos-router.service
Environment=
Environment="MIBDIRS=/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/vyos/mibs"
ExecStart=
-ExecStart={{vrf_command}}/usr/sbin/snmpd -LS0-5d -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -ipCidrRouteTable,inetCidrRouteTable -f -p /run/snmpd.pid
+ExecStart={{vrf_command}}/usr/sbin/snmpd -LS0-5d -Lf /dev/null -u Debian-snmp -g Debian-snmp {{oid_route_table}} -f -p /run/snmpd.pid
Restart=always
RestartSec=10
diff --git a/interface-definitions/snmp.xml.in b/interface-definitions/snmp.xml.in
index f57103eac..2654449a1 100644
--- a/interface-definitions/snmp.xml.in
+++ b/interface-definitions/snmp.xml.in
@@ -129,6 +129,26 @@
<constraintErrorMessage>Location is limited to 255 characters or less</constraintErrorMessage>
</properties>
</leafNode>
+ <leafNode name="oid-enable">
+ <properties>
+ <help>Enable specific oids</help>
+ <valueHelp>
+ <format>txt</format>
+ <description>Enable specific oids</description>
+ </valueHelp>
+ <valueHelp>
+ <format>route-table</format>
+ <description>Enable route table oids (ipCidrRouteTable inetCidrRouteTable)</description>
+ </valueHelp>
+ <completionHelp>
+ <list>route-table</list>
+ </completionHelp>
+ <constraint>
+ <regex>^(route-table)$</regex>
+ </constraint>
+ <constraintErrorMessage>Oid must be 'route-table'</constraintErrorMessage>
+ </properties>
+ </leafNode>
<leafNode name="smux-peer">
<properties>
<help>Register a subtree for SMUX-based processing</help>
diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py
index 3990e5735..23e45a5b7 100755
--- a/src/conf_mode/snmp.py
+++ b/src/conf_mode/snmp.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2018-2020 VyOS maintainers and contributors
+# Copyright (C) 2018-2021 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -54,6 +54,7 @@ default_config_data = {
'location' : '',
'description' : '',
'contact' : '',
+ 'route_table': 'False',
'trap_source': '',
'trap_targets': [],
'vyos_user': '',
@@ -186,6 +187,9 @@ def get_config():
snmp['script_ext'].append(extension)
+ if conf.exists('oid-enable route-table'):
+ snmp['route_table'] = True
+
if conf.exists('vrf'):
# Append key to dict but don't place it in the default dictionary.
# This is required to make the override.conf.tmpl work until we