解决LUCI编译statistics组件后,在更改接口时候会出现如下错误
如图
更改以上设置或者其他选项中的设置后,返回到graph,图表选项卡 会出现以下错误
/usr/lib/lua/luci/dispatcher.lua:448: Failed to execute call dispatcher target for entry ‘/admin/statistics/graph/load’.
The called action terminated with an exception:
/usr/lib/lua/luci/util.lua:209: attempt to get length of local ‘str’ (a nil value)
stack traceback:
[C]: in function ‘assert’
/usr/lib/lua/luci/dispatcher.lua:448: in function ‘dispatch’
/usr/lib/lua/luci/dispatcher.lua:195: in function
检查后发现由于是权限不足。statistics每次更改后会重新创建一份文件保存在/etc/config下面,但运行的是在非root用户权限下,所以由于权限不足导致问题发生。参见:https://dev.openwrt.org/ticket/10536
解决方法:
打开/etc/init.d/luci_statistics文件,插入以下字段(粗体内容),插入chmod 0755 /etc/config/luci_statistics
#!/bin/sh /etc/rc.common
START=79start() {
### replace shipped config with symlink
if [ ! -L /etc/collectd.conf ]; then
test -f /etc/collectd.conf && mv /etc/collectd.conf /etc/collectd.conf.bak
ln -s /var/etc/collectd.conf /etc/collectd.conf
fi### create config
mkdir -p /var/etc
/usr/bin/stat-genconfig > /var/etc/collectd.conf### prepare rrdimg directory
if [ -f /etc/config/lucid ] && [ -x /etc/init.d/lucid ] && /etc/init.d/lucid enabled && \
[ “$(uci get luci_statistics.rrdtool.image_path 2>/dev/null)” != “$(uci get lucid.statistics.physical 2>/dev/null)” ]; then
uci set lucid.statistics.physical=$(uci get luci_statistics.rrdtool.image_path)
uci commit lucid
/etc/init.d/lucid restart
fi### workaround broken permissions on /tmp
chmod 1777 /tmp
chmod 0755 /etc/config/luci_statistics
}restart() {
### regenerate config / prepare environment
start### restart collectd
/etc/init.d/collectd restart
}
保存后问题即可解决。
[分享]解决Luci-statistics更改接口后出现错误:等您坐沙发呢!