Snmpd configuration on LEDE SDK

I am using openwrt 17.02 LEDE for a router based project. I am trying to write to /etc/config/snmpd from my lua file in model/cbi. I am taking input from GUI and the input is being sent to /etc/config/snmpd using uci commands. Following is the code snippet from my lua file :

function m3.on_commit(map)
local uci = require("luci.model.uci").cursor()
local location = self:formvalue("cbid.snmp.snmpd.location")
local contact = self:formvalue("cbid.snmp.snmpd.contact")
local name = self:formvalue("cbid.snmp.snmpd.name")
local ro_community = self:formvalue("cbid.snmp.snmpd.ro_community")
local rw_community = self:formvalue("cbid.snmp.snmpd.rw_community")

-- Send values to /etc/config/snmpd
uci:set("snmpd", "system", "sysLocation", location)
uci:set("snmpd", "system", "sysContact", contact)
uci:set("snmpd", "system", "sysName", name)

-- Configure com2sec for public ro
uci:section("snmpd", "com2sec", "public", {
secname = "ro",
source = "default",
community = ro_community
})

-- Configure com2sec for private RW
    uci:section("snmpd", "com2sec", "private", {
    secname = "rw",
    source = "localhost",
    community = rw_community
    })

uci:commit("snmpd")
luci.sys.call("/etc/init.d/snmpd restart")

end

But on clicking the save and apply in the GUI, I getting error : "bad argument #4 to 'set' (string expected, got nil)" for uci:set command.

I have checked the HTML form for the textbox entries and I had put the same values but I am not able to understand what I doing wrong with the formvalues command.

LEDE is EOL since a very long time, upgrade ...

The SDKs we are using is supported by openwrt 17 and not the latest one. Hence we are moving forward with this.

It appears you are using firmware that is not from the official OpenWrt project.

When using forks/offshoots/vendor-specific builds that are "based on OpenWrt", there may be many differences compared to the official versions (hosted by OpenWrt.org). Some of these customizations may fundamentally change the way that OpenWrt works. You might need help from people with specific/specialized knowledge about the firmware you are using, so it is possible that advice you get here may not be useful.

You may find that the best options are:

  1. Install an official version of OpenWrt, if your device is supported (see https://firmware-selector.openwrt.org).
  2. Ask for help from the maintainer(s) or user community of the specific firmware that you are using.
  3. Provide the source code for the firmware so that users on this forum can understand how your firmware works (OpenWrt forum users are volunteers, so somebody might look at the code if they have time and are interested in your issue).

If you believe that this specific issue is common to generic/official OpenWrt and/or the maintainers of your build have indicated as such, please feel free to clarify.

I believe this to be a generic issue as I feel this is a logical error. Hence, I needed some guidance on it.

then ask the people who provided you with the SDK, I'm sure they'll be happy to assist you (for a fee).
for us, this is a black box.

oh, and did I say it's f*ing old, too ?

1 Like

Yeah, I do know it's old. But I just needed help on the logic flow from a lua file in a Luci framework to config file in /etc. What more information would you require for it?

In addition to a long since EOL'd (and unsupported) version of OpenWrt, since the SDK is not provided by OpenWrt, you do need to ask the vendor who provided the SDK. Within the OpenWrt mainline, things have changed significantly such that an answer for a modern version wouldn't likely apply (and it's unlikely that anyone will remember the nuances for a version that is 6 years old here, anyway). Further, since the vendor almost certainly made significant changes to the code as compared to official OpenWrt, it becomes unsupportable here, anyway.

Please reach out to the vendor of the hardware and/or SDK.