luci-app-snmpd: group options in tabs

This commit groups the existing options in a general tabs and advanced tab.
It also prepares to add additional tabs for SNMPv1/v2c and SNMPv3 in the
future.

Signed-off-by: Christian Korber <ck@dev.tdt.de>
This commit is contained in:
Christian Korber
2025-07-04 12:25:43 +02:00
committed by Paul Donald
parent a2d0f5e2b3
commit 4ea7888909

View File

@@ -5,59 +5,172 @@
'require ui';
'require view';
var desc = _(""
+ "SNMPD is a master daemon/agent for SNMP, from the <a href='http://www.net-snmp.org'>"
+ "net-snmp project</a>. "
+ "Note, OpenWrt has mostly complete UCI support for snmpd, but this LuCI applet "
+ "only covers a few of those options. In particular, there is very little/no validation "
+ "or help. See /etc/config/snmpd for manual configuration."
);
return view.extend({
return L.view.extend({
render: function() {
let m, s, o;
let m, s, o, g, go;
m = new form.Map("snmpd", _("net-snmp's SNMPD"), desc);
m = new form.Map('snmpd',
_('SNMP Settings'),
_('On this page you may configure SNMP settings'));
s = m.section(form.TypedSection, "agent", _("Agent settings"));
s = m.section(form.TypedSection, 'snmpd');
s.anonymous = true;
o = s.option(form.Value, "agentaddress", _("The address the agent should listen on"),
_("Eg: UDP:161, or UDP:10.5.4.3:161 to only listen on a given interface"));
s.addremove = false;
s = m.section(form.TypedSection, "agentx", _("AgentX settings"),
_("Delete this section to disable AgentX"));
s.anonymous = true;
o = s.option(form.Value, "agentxsocket", _("The address the agent should allow AgentX connections to"),
_("This is only necessary if you have subagents using the agentX "
+ "socket protocol. Eg: /var/run/agentx.sock"));
s.addremove = true;
s.tab('general', _('SNMP - General'));
s = m.section(form.TypedSection, "com2sec", _("com2sec security"));
o = s.option(form.Value, "secname", "secname");
o = s.option(form.Value, "source", "source");
o = s.option(form.Value, "community", "community");
o = s.taboption('general', form.SectionValue, '__general__',
form.TypedSection, 'system', _('System settings'),
_('Here you can configure system settings'));
s = m.section(form.TypedSection, "group", "group", _("Groups help define access methods"));
s.addremove = true;
s.option(form.Value, "group", "group");
s.option(form.Value, "version", "version");
s.option(form.Value, "secname", "secname");
g = o.subsection;
g.anonymous = true;
g.addremove = false;
s = m.section(form.TypedSection, "access", "access");
s.option(form.Value, "group", "group");
s.option(form.Value, "context", "context");
s.option(form.Value, "version", "version");
s.option(form.Value, "level", "level");
s.option(form.Value, "prefix", "prefix");
s.option(form.Value, "read", "read");
s.option(form.Value, "write", "write");
s.option(form.Value, "notify", "notify");
go = g.option(form.Value, 'sysLocation', 'sysLocation');
go = g.option(form.Value, 'sysContact', 'sysContact');
go = g.option(form.Value, 'sysName', 'sysName');
s = m.section(form.TypedSection, "system", _("System"), _("Values used in the MIB2 System tree"));
s.anonymous = true;
s.option(form.Value, "sysLocation", "sysLocation");
s.option(form.Value, "sysContact", "sysContact");
s.option(form.Value, "sysName", "sysName");
o = s.taboption('general', form.SectionValue, '__general__',
form.TypedSection, 'snmpd', _('Common Settings'),
_('Here you can configure common settings'));
g = o.subsection;
g.anonymous = true;
g.addremove = false;
go = g.option(form.Flag, 'enabled', _('Enable SNMP'),
_('Enable to use SNMP'));
go.default = '0';
go.rmempty = false;
go = g.option(form.Value, 'agentaddress', _('The address the agent should listen on'),
_('Eg: UDP:161, or UDP:10.5.4.3:161 to only listen on a given interface'));
go = g.option(form.Value, 'agentxsocket', _('The address the agent should allow AgentX connections to'),
_('This is only necessary if you have subagents using the agentX '
+ 'socket protocol. Eg: /var/run/agentx.sock'));
s.tab('advanced', _('Advanced Settings'));
o = s.taboption('advanced', form.SectionValue, '__advanced__',
form.GridSection, 'com2sec', null,
_('Here you can configure com2sec options'));
g = o.subsection;
g.anonymous = true;
g.addremove = true;
go = g.option(form.Value, 'secname', _('Secname'),
_('Arbitrary label for use in group settings'));
go.optional = false;
go.rmempty = false;
go = g.option(form.Value, 'source', _('Source'),
_('Source describes a host or network'));
go.rmempty = false;
go = g.option(form.Value, 'community', _('Community'),
_('The community name that is used'));
go.optional = false;
go.rmempty = false;
o = s.taboption('advanced', form.SectionValue, '__advanced__',
form.GridSection, 'group', null,
_('Here you can configure group options'));
g = o.subsection;
g.anonymous = true;
g.addremove = true;
go = g.option(form.Value, 'group', _('Group'),
_('A group maps com2sec names to access names'));
go.optional = false;
go.rmempty = false;
go = g.option(form.Value, 'version', _('Version'),
_('The used version for the group'));
go.value('v1', _('SNMPv1'));
go.value('v2c' _('SNMPv2c'));
go.value('usm', _('SNMPv3'));
go.optional = false;
go.rmempty = false;
go = g.option(form.Value, 'secname', _('Secname'),
_('Here you define which secname is mapped to the group'));
go.optional = false;
go.rmempty = false;
o = s.taboption('advanced', form.SectionValue, '__advanced__',
form.GridSection, 'access', null,
_('Here you can configure access options'));
g = o.subsection;
g.anonymous = true;
g.addremove = true;
go = g.option(form.Value, 'group', _('Group'),
_('The group that is mapped to the views (Read, Write, Notify)'));
go.optional = false;
go.rmempty = false;
go = g.option(form.Value, 'context', _('Context'),
_('The context of the request'));
go.default = 'none';
go.modalonly = true;
go = g.option(form.Value, 'version', _('Version'),
_('The used version for access configuration'));
go.value('any', _('Any version'));
go.value('v1', _('SNMPv1'));
go.value('v2c' _('SNMPv2c'));
go.value('usm', _('SNMPv3'));
go.optional = false;
go.rmempty = false;
go = g.option(form.Value, 'level', _('Level'),
_('Level of security'));
go.value('noauth', _('No authentication (standard for SNMPv1/v2c)'));
go.value('auth', _('Authentication'));
go.value('priv', _('Authentication and encryption'));
go.default = 'noauth';
go.optional = false;
go.rmempty = false;
go = g.option(form.Value, 'prefix', _('Prefix'),
_('Specification how context of requests is matched to context'));
go.value('exact', _('Exact'));
go.value('prefix', _('Prefix'));
go.optional = false;
go.default = 'excact';
go.rmempty = false;
go = g.option(form.Value, 'read', _('Read'),
_('Read access modification for groups'));
go.value('all', _('All'));
go.value('none', _('None'));
go.default = 'none';
go.rmempty = false;
go.modalonly = true;
go.optional = false;
go = g.option(form.Value, 'write', _('Write'),
_('Write access modification for groups'));
go.value('all', _('All'));
go.value('none', _('None'));
go.default = 'none';
go.rmempty = false;
go.modalonly = true;
go.optional = false;
go = g.option(form.Value, 'notify', _('Notify'),
_('Notify access modification for groups'));
go.value('all', _('All'));
go.value('none', _('None'));
go.default = 'none';
go.rmempty = false;
go.modalonly = true;
go.optional = false;
return m.render();
}