Browse Source

smartsnmpd: remove dysfunctional package

This package has been completely broken on several levels since
commit eadd5abe40 ("smartsnmpd: Update to 2015-02-22 version")

The update changed the configuration file syntax without fixing
the scripts generating this file.  The OpenWrt package would
therefore fail to run.

Worse than that, the last upstream version is completely broken
is unable to generate proper snmp replies even if the
configuration file is fixed, This has been tested and verified
on both OpenWrt/realtek and Debian/amd64.

I considered fixing the package, but dropped it for the following
reasons
 1) upstream has abandoned the project
 2) the upstream fork "smithsnmp" continues to make aribitrary
    changes to configuration files and other packaging challenges
 3) the package is tied to the lua5.1 C API, and further upgrades
    will be non-trivial
 4) there are several other snmp daemons available in OpenWrt,
    without any of these issues
 5) no one is interested in this package

The last point is proven by the lack of testing and feedback.
The last update was not even tested by the person preparing and
commiting the update.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
lilik-openwrt-22.03
Bjørn Mork 4 years ago
parent
commit
e62da3eebd
No known key found for this signature in database GPG Key ID: 22044ECBBFA4615D
8 changed files with 0 additions and 605 deletions
  1. +0
    -84
      net/smartsnmpd/Makefile
  2. +0
    -24
      net/smartsnmpd/files/mibs/dummy.lua
  3. +0
    -125
      net/smartsnmpd/files/mibs/interfaces.lua
  4. +0
    -176
      net/smartsnmpd/files/mibs/system.lua
  5. +0
    -21
      net/smartsnmpd/files/smartsnmpd.conf
  6. +0
    -49
      net/smartsnmpd/files/smartsnmpd.init
  7. +0
    -82
      net/smartsnmpd/patches/010-2to3.patch
  8. +0
    -44
      net/smartsnmpd/patches/020-flags.patch

+ 0
- 84
net/smartsnmpd/Makefile View File

@ -1,84 +0,0 @@
#
# Copyright (C) 2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=smartsnmpd
PKG_VERSION:=2015-02-22
PKG_RELEASE:=2
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/credosemi/smartsnmp
PKG_SOURCE_VERSION:=ca1d455fd06748caa629fe7ad16a47cec8877b93
PKG_MIRROR_HASH:=fda89ec37944b4f800eb3c0147678745b57f08c87f10d246d3c9d165a43418b4
PKG_MAINTAINER:=Xiongfei Guo <xfguo@credosemi.com>
PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=scons/host
include $(INCLUDE_DIR)/package.mk
include ../../devel/scons/scons.mk
define Package/smartsnmpd
SECTION:=net
CATEGORY:=Network
DEPENDS+=+lua +liblua +libubox +libuci-lua +libubus-lua
TITLE:=Smart-SNMP (Agent)
URL:=https://github.com/credosemi/smartsnmp
endef
define Package/smartsnmpd/description
smartsnmpd is an implementation of SNMP Agent. Its goal is "Easily
writing boring SNMP MIB with Lua". This package add native support
for OpenWrt. Include using ubus and uci to get system info/status.
And, it use libubox/uloop as low level event-driven library.
endef
ifeq ($(CONFIG_BIG_ENDIAN),y)
TARGET_CFLAGS += -DBIG_ENDIAN
else
TARGET_CFLAGS += -DLITTLE_ENDIAN
endif
SCONS_OPTIONS += --transport=uloop
define Build/Configure
(cd $(PKG_BUILD_DIR); \
$(SCONS_VARS) \
CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
scons \
prefix=/usr \
$(SCONS_OPTIONS) \
)
endef
define Package/smartsnmpd/conffiles
/etc/config/smartsnmpd
endef
define Package/smartsnmpd/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/smartsnmpd $(1)/usr/sbin/smartsnmpd
$(INSTALL_DIR) $(1)/usr/lib/lua/smartsnmp
$(INSTALL_BIN) $(PKG_BUILD_DIR)/build/smartsnmp/core.so $(1)/usr/lib/lua/smartsnmp/core.so
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lualib/smartsnmp/*.lua $(1)/usr/lib/lua/smartsnmp/
$(INSTALL_DIR) $(1)/usr/lib/lua/smartsnmp/mibs
$(INSTALL_BIN) ./files/mibs/*.lua $(1)/usr/lib/lua/smartsnmp/mibs/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/smartsnmpd.conf $(1)/etc/config/smartsnmpd
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/smartsnmpd.init $(1)/etc/init.d/smartsnmpd
endef
$(eval $(call BuildPackage,smartsnmpd))

+ 0
- 24
net/smartsnmpd/files/mibs/dummy.lua View File

@ -1,24 +0,0 @@
--
-- This file is part of SmartSNMP
-- Copyright (C) 2014, Credo Semiconductor Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
local mib = require "smartsnmp"
local dummy = {}
return dummy

+ 0
- 125
net/smartsnmpd/files/mibs/interfaces.lua View File

@ -1,125 +0,0 @@
--
-- This file is part of SmartSNMP
-- Copyright (C) 2014, Credo Semiconductor Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
local mib = require "smartsnmp"
require "ubus"
require "uloop"
uloop.init()
local conn = ubus.connect()
if not conn then
error("Failed to connect to ubusd")
end
local if_cache = {}
local if_status_cache = {}
local if_index_cache = {}
local last_load_time = os.time()
local function need_to_reload()
if os.time() - last_load_time >= 3 then
last_load_time = os.time()
return true
else
return false
end
end
local function load_config()
if need_to_reload() == true then
if_cache = {}
if_status_cache = {}
if_index_cache = {}
-- if description
for k, v in pairs(conn:call("network.device", "status", {})) do
if_status_cache[k] = {}
end
for name_ in pairs(if_status_cache) do
for k, v in pairs(conn:call("network.device", "status", { name = name_ })) do
if k == 'mtu' then
if_status_cache[name_].mtu = v
elseif k == 'macaddr' then
if_status_cache[name_].macaddr = v
elseif k == 'up' then
if v == true then
if_status_cache[name_].up = 1
else
if_status_cache[name_].up = 2
end
elseif k == 'statistics' then
for item, stat in pairs(v) do
if item == 'rx_bytes' then
if_status_cache[name_].in_octet = stat
elseif item == 'tx_bytes' then
if_status_cache[name_].out_octet = stat
elseif item == 'rx_errors' then
if_status_cache[name_].in_errors = stat
elseif item == 'tx_errors' then
if_status_cache[name_].out_errors = stat
elseif item == 'rx_dropped' then
if_status_cache[name_].in_discards = stat
elseif item == 'tx_dropped' then
if_status_cache[name_].out_discards = stat
end
end
end
end
end
if_cache['desc'] = {}
for name, status in pairs(if_status_cache) do
table.insert(if_cache['desc'], name)
for k, v in pairs(status) do
if if_cache[k] == nil then if_cache[k] = {} end
table.insert(if_cache[k], v)
end
end
-- if index
for i in ipairs(if_cache['desc']) do
table.insert(if_index_cache, i)
end
end
end
mib.module_methods.or_table_reg("1.3.6.1.2.1.2", "The MIB module for managing Interfaces implementations")
local ifGroup = {
[1] = mib.ConstInt(function () load_config() return #if_index_cache end),
[2] = {
[1] = {
[1] = mib.ConstIndex(function () load_config() return if_index_cache end),
[2] = mib.ConstString(function (i) load_config() return if_cache['desc'][i] end),
[4] = mib.ConstInt(function (i) load_config() return if_cache['mtu'][i] end),
[6] = mib.ConstString(function (i) load_config() return if_cache['macaddr'][i] end),
[8] = mib.ConstInt(function (i) load_config() return if_cache['up'][i] end),
[10] = mib.ConstCount(function (i) load_config() return if_cache['in_octet'][i] end),
[13] = mib.ConstCount(function (i) load_config() return if_cache['in_discards'][i] end),
[14] = mib.ConstCount(function (i) load_config() return if_cache['in_errors'][i] end),
[16] = mib.ConstCount(function (i) load_config() return if_cache['out_octet'][i] end),
[19] = mib.ConstCount(function (i) load_config() return if_cache['out_discards'][i] end),
[20] = mib.ConstCount(function (i) load_config() return if_cache['out_errors'][i] end),
}
}
}
return ifGroup

+ 0
- 176
net/smartsnmpd/files/mibs/system.lua View File

@ -1,176 +0,0 @@
--
-- This file is part of SmartSNMP
-- Copyright (C) 2014, Credo Semiconductor Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
local mib = require "smartsnmp"
local uci = require "uci"
-- System config
local context = uci.cursor("/etc/config", "/tmp/.uci")
-- scalar index
local sysDesc = 1
local sysObjectID = 2
local sysUpTime = 3
local sysContact = 4
local sysName = 5
local sysLocation = 6
local sysServices = 7
local sysORLastChange = 8
-- table index
local sysORTable = 9
-- entry index
local sysOREntry = 1
-- list index
local sysORIndex = 1
local sysORID = 2
local sysORDesc = 3
local sysORUpTime = 4
local startup_time = 0
local or_last_changed_time = 0
local function mib_system_startup(time)
startup_time = time
or_last_changed_time = time
end
mib_system_startup(os.time())
local sysGroup = {}
local or_oid_cache = {}
local or_index_cache = {}
local or_table_cache = {}
local or_table_reg = function (oid, desc)
local row = {}
row['oid'] = {}
for i in string.gmatch(oid, "%d") do
table.insert(row['oid'], tonumber(i))
end
row['desc'] = desc
row['uptime'] = os.time()
table.insert(or_table_cache, row)
or_last_changed_time = os.time()
or_oid_cache[oid] = #or_table_cache
or_index_cache = {}
for i in ipairs(or_table_cache) do
table.insert(or_index_cache, i)
end
end
local or_table_unreg = function (oid)
local or_idx = or_oid_cache[oid]
if or_table_cache[or_idx] ~= nil then
table.remove(or_table_cache, or_idx)
or_last_changed_time = os.time()
or_index_cache = {}
for i in ipairs(or_table_cache) do
table.insert(or_index_cache, i)
end
end
end
local last_load_time = os.time()
local function need_to_reload()
if os.difftime(os.time(), last_load_time) < 3 then
return false
else
last_load_time = os.time()
return true
end
end
local function load_config()
if need_to_reload() == true then
context:load("smartsnmpd")
end
end
context:load("smartsnmpd")
local sysMethods = {
["or_table_reg"] = or_table_reg,
["or_table_unreg"] = or_table_unreg
}
mib.module_method_register(sysMethods)
sysGroup = {
rocommunity = 'public',
[sysDesc] = mib.ConstString(function () load_config() return mib.sh_call("uname -a") end),
[sysObjectID] = mib.ConstOid(function ()
load_config()
local oid
local objectid
context:foreach("smartsnmpd", "smartsnmpd", function (s)
objectid = s.objectid
end)
if objectid ~= nil then
oid = {}
for i in string.gmatch(objectid, "%d+") do
table.insert(oid, tonumber(i))
end
end
return oid
end),
[sysUpTime] = mib.ConstTimeticks(function () load_config() return os.difftime(os.time(), startup_time) * 100 end),
[sysContact] = mib.ConstString(function ()
load_config()
local contact
context:foreach("smartsnmpd", "smartsnmpd", function (s)
contact = s.contact
end)
return contact
end),
[sysName] = mib.ConstString(function () load_config() return mib.sh_call("uname -n") end),
[sysLocation] = mib.ConstString(function ()
load_config()
local location
context:foreach("smartsnmpd", "smartsnmpd", function (s)
location = s.location
end)
return location
end),
[sysServices] = mib.ConstInt(function ()
load_config()
local services
context:foreach("smartsnmpd", "smartsnmpd", function (s)
services = tonumber(s.services)
end)
return services
end),
[sysORLastChange] = mib.ConstTimeticks(function () load_config() return os.difftime(os.time(), or_last_changed_time) * 100 end),
[sysORTable] = {
[sysOREntry] = {
[sysORIndex] = mib.UnaIndex(function () load_config() return or_index_cache end),
[sysORID] = mib.ConstOid(function (i) load_config() return or_table_cache[i].oid end),
[sysORDesc] = mib.ConstString(function (i) load_config() return or_table_cache[i].desc end),
[sysORUpTime] = mib.ConstTimeticks(function (i) load_config() return os.difftime(os.time(), or_table_cache[i].uptime) * 100 end),
}
}
}
return sysGroup

+ 0
- 21
net/smartsnmpd/files/smartsnmpd.conf View File

@ -1,21 +0,0 @@
config smartsnmpd
option port '161'
option ro_community 'public'
option rw_community 'private'
option mib_module_path 'mibs'
option objectid '1.2.3.4'
option contact 'Me <me@example.org>'
option location 'Shanghai'
option services '72'
config smartsnmpd_module
option oid "1.3.6.1.2.1.1"
option module 'system'
config smartsnmpd_module
option oid "1.3.6.1.2.1.2"
option module 'interfaces'
config smartsnmpd_module
option oid "1.3.6.1.1"
option module 'dummy'

+ 0
- 49
net/smartsnmpd/files/smartsnmpd.init View File

@ -1,49 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2014 OpenWrt.org
START=97
USE_PROCD=1
PROG=/usr/sbin/smartsnmpd
CONFIGFILE=/etc/smartsnmpd.conf
smartsnmpd_mib_module() {
local cfg="$1"
config_get OID "$cfg" oid
config_get MODULE "$cfg" module
echo " ['$OID'] = '$MODULE'," >> $CONFIGFILE
}
start_service() {
include /lib/functions
config_load smartsnmpd
procd_open_instance
procd_set_param command $PROG -c $CONFIGFILE
procd_set_param file $CONFIGFILE
procd_set_param respawn
procd_close_instance
# before we can call xappend
mkdir -p "$(dirname $CONFIGFILE)"
echo "-- auto-generated config file from /etc/config/smartsnmpd" > $CONFIGFILE
{
config_get PORT smartsnmpd port 161
echo "port = $PORT"
config_get RO_COMMUNITY smartsnmpd ro_community 'public'
config_get RW_COMMUNITY smartsnmpd rw_community 'private'
echo "ro_community = '$RO_COMMUNITY'"
echo "rw_community = '$RW_COMMUNITY'"
config_get MIB_MODULE_PATH smartsnmpd mib_module_path '/usr/lib/lua/smartsnmp/mibs/'
echo "mib_module_path = '$MIB_MODULE_PATH'"
echo "mib_modules = {"
config_foreach smartsnmpd_mib_module smartsnmpd_module
echo "}"
} >> $CONFIGFILE
}

+ 0
- 82
net/smartsnmpd/patches/010-2to3.patch View File

@ -1,82 +0,0 @@
--- a/SConstruct
+++ b/SConstruct
@@ -133,21 +133,21 @@ env = Environment(
)
# handle options/environment varibles.
-if os.environ.has_key('CC'):
+if 'CC' in os.environ:
env.Replace(CC = os.environ['CC'])
# CFLAGS
if GetOption("cflags") != "":
env.Append(CFLAGS = GetOption("cflags"))
-elif os.environ.has_key('CFLAGS'):
+elif 'CFLAGS' in os.environ:
env.Append(CFLAGS = os.environ['CFLAGS'])
# LDFLAGS
if GetOption("ldflags") != "":
env.Replace(LINKFLAGS = GetOption("ldflags"))
-elif os.environ.has_key('LDFLAGS'):
+elif 'LDFLAGS' in os.environ:
env.Replace(LINKFLAGS = os.environ['LDFLAGS'])
-elif os.environ.has_key('LINKFLAGS'):
+elif 'LINKFLAGS' in os.environ:
env.Replace(LINKFLAGS = os.environ['LINKFLAGS'])
# LIBS
@@ -183,10 +183,10 @@ elif GetOption("transport") == 'built-in' or GetOption("transport") == '':
elif GetOption("evloop") == 'select' or GetOption("evloop") == '':
pass
else:
- print "Error: Not the right event driving type"
+ print("Error: Not the right event driving type")
Exit(1)
else:
- print "Error: Transport not found!"
+ print("Error: Transport not found!")
Exit(1)
# autoconf
@@ -205,18 +205,18 @@ else:
if GetOption("transport") == 'built-in' or GetOption("transport") == '':
if GetOption("evloop") == 'epoll':
if not conf.CheckEpoll():
- print "Error: epoll failed"
+ print("Error: epoll failed")
Exit(1)
elif GetOption("evloop") == 'kqueue':
if not conf.CheckKqueue():
- print "Error: Kqueue failed"
+ print("Error: Kqueue failed")
Exit(1)
elif GetOption("evloop") == 'select' or GetOption("evloop") == '':
if not conf.CheckSelect():
- print "Error: select failed"
+ print("Error: select failed")
Exit(1)
else:
- print "Error: Not the right event driving type"
+ print("Error: Not the right event driving type")
Exit(1)
# CFLAGS
@@ -232,7 +232,7 @@ if conf.CheckLib('lua'):
elif conf.CheckLib('lua5.1'):
env.Append(LIBS = ['lua5.1'])
else:
- print "Error: liblua or liblua5.1 not found!"
+ print("Error: liblua or liblua5.1 not found!")
Exit(1)
# find lua header files
@@ -241,7 +241,7 @@ if conf.CheckCHeader('lua.h'):
elif conf.CheckCHeader('lua5.1/lua.h'):
env.Append(CFLAGS = ['-I/usr/include/lua5.1'])
else:
- print "Error: lua.h not found"
+ print("Error: lua.h not found")
Exit(1)
env = conf.Finish()

+ 0
- 44
net/smartsnmpd/patches/020-flags.patch View File

@ -1,44 +0,0 @@
--- a/SConstruct
+++ b/SConstruct
@@ -134,21 +134,21 @@ env = Environment(
# handle options/environment varibles.
if 'CC' in os.environ:
- env.Replace(CC = os.environ['CC'])
+ env.Replace(CC = Split(os.environ['CC']))
# CFLAGS
if GetOption("cflags") != "":
env.Append(CFLAGS = GetOption("cflags"))
elif 'CFLAGS' in os.environ:
- env.Append(CFLAGS = os.environ['CFLAGS'])
+ env.Append(CFLAGS = Split(os.environ['CFLAGS']))
# LDFLAGS
if GetOption("ldflags") != "":
env.Replace(LINKFLAGS = GetOption("ldflags"))
elif 'LDFLAGS' in os.environ:
- env.Replace(LINKFLAGS = os.environ['LDFLAGS'])
+ env.Replace(LINKFLAGS = Split(os.environ['LDFLAGS']))
elif 'LINKFLAGS' in os.environ:
- env.Replace(LINKFLAGS = os.environ['LINKFLAGS'])
+ env.Replace(LINKFLAGS = Split(os.environ['LINKFLAGS']))
# LIBS
if GetOption("libs") != "":
@@ -192,15 +192,6 @@ else:
# autoconf
conf = Configure(env, custom_tests = {'CheckEpoll' : CheckEpoll, 'CheckSelect' : CheckSelect, 'CheckKqueue' : CheckKqueue, 'CheckEndian' : CheckEndian})
-# Endian check
-endian = conf.CheckEndian()
-if endian == 'Big':
- env.Append(CFLAGS = ["-DBIG_ENDIAN"])
-elif endian == 'Little':
- env.Append(CFLAGS = ["-DLITTLE_ENDIAN"])
-else:
- raise SConfError("Error when testing the endian.")
-
# built-in event loop check
if GetOption("transport") == 'built-in' or GetOption("transport") == '':
if GetOption("evloop") == 'epoll':

Loading…
Cancel
Save