Trouble with luci-app-statistics using Storage Directory on USB drive [Solved]

Update and Solution: The solution was to ensure that all directories are readable by 'nobody'. See the updated luci-app-statistics page in the wiki for more about that package. (Note: Link updated 3Feb2023)

Original problem statement... Using LEDE 17.01.4 with external USB drive installed at /opt Everything works fine if I leave the Storage directory at the default /tmp/rrd.

But I wanted the data to be preserved across reboots, so I used the LuCI GUI to change the Storage directory to the USB drive in a directory at /opt/rrd. Now the message I see on the web page when trying to display the expected chart is:

/usr/lib/lua/luci/dispatcher.lua:460: Failed to execute call dispatcher target for entry '/admin/statistics/graph/uptime'.
The called action terminated with an exception:
/usr/lib/lua/luci/statistics/datatree.lua:159: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
	[C]: in function 'assert'
	/usr/lib/lua/luci/dispatcher.lua:460: in function 'dispatch'
	/usr/lib/lua/luci/dispatcher.lua:141: in function </usr/lib/lua/luci/dispatcher.lua:140>

Potentially interesting diagnostic info:

  • After installing collectd & collectd-mod-uptime, I installed luci-app-statistics and got the message:

     root@LEDE-ArcherC7:/etc/config# opkg install luci-app-statistics
    Installing luci-app-statistics (git-18.007.32064-ff21f2f-1) to root...
    Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/luci/luci-app-statistics_git-18.007.32064-ff21f2f-1_all.ipk
    Configuring luci-app-statistics.
    uci: Entry not found
    

    Why did it say, uci: Entry not found? Is that a problem?

  • This worked fine when installing those packages onto another router with 17.04.02. Specifically, I changed Storage directory to /opt/rrd and the charts continued to work.

  • I have read elsewhere that permissions might be a problem. Here's what I show for the affected router (permissions for all directories are 755, the uptime.rrd file itself is 644):

    root@LEDE-ArcherC7:/opt# ls -al
    drwx------    5 1000     1000          4096 Jan 15 09:39 .
    drwxr-xr-x    1 root     root             0 Jan 14 19:45 ..
    -rw-r--r--    1 root     root             0 Dec 18 17:24 3.2.1
    drwxrwxr-x    9 root     root          4096 Dec 18 17:24 YAMon3
    -rwxr-xr-x    1 root     root          6450 Nov 13 13:34 install.sh
    drwx------    2 root     root         16384 Oct 25 22:55 lost+found
    drwxr-xr-x    3 root     root          4096 Jan 15 09:39 rrd
    root@LEDE-ArcherC7:/opt# ls -al rrd
    drwxr-xr-x    3 root     root          4096 Jan 15 09:39 .
    drwx------    5 1000     1000          4096 Jan 15 09:39 ..
    drwxr-xr-x    8 root     root          4096 Jan 15 09:39 LEDE-ArcherC7
    root@LEDE-ArcherC7:/opt# ls -al rrd/LEDE-ArcherC7/
    drwxr-xr-x    8 root     root          4096 Jan 15 09:39 .
    drwxr-xr-x    3 root     root          4096 Jan 15 09:39 ..
    drwxr-xr-x    2 root     root          4096 Jan 15 09:39 interface-br-lan
    drwxr-xr-x    2 root     root          4096 Jan 15 09:39 iwinfo-wlan0
    drwxr-xr-x    2 root     root          4096 Jan 15 09:39 iwinfo-wlan1
    drwxr-xr-x    2 root     root          4096 Jan 15 09:39 load
    drwxr-xr-x    2 root     root          4096 Jan 15 09:39 memory
    drwxr-xr-x    2 root     root          4096 Jan 15 09:39 uptime
    root@LEDE-ArcherC7:/opt# ls -al rrd/LEDE-ArcherC7/uptime/
    drwxr-xr-x    2 root     root          4096 Jan 15 09:39 .
    drwxr-xr-x    9 root     root          4096 Jan 15 09:40 ..
    -rw-r--r--    1 root     root          5544 Jan 15 09:40 uptime.rrd
    

Thoughts? What other info could I supply?

I also have moved my statistics database to a USB drive, so it works. The "uci: Entry not found" message means that there is an error on some file at "/etc/config"; I would start by checking all files. You can also post here the relevant config files, and I can compare them to mine.

The luci page rendering the stats is running as nobody user so check if it can read the rrd directory including all its parent directories

Bingo! The top-level /opt directory was 700 (see ls -al above). Changing that to 755 (chmod 755 /opt) solved the problem.

Marginally-related question: I installed the USB drive using Quick Start for Adding USB Drive. That left the top-level directory with permissions of 700 (I believe - I did it a long time ago. I certainly didn't set it to 700 on purpose.)

What advice might be useful/necessary for that quick start guide to avoid the problem I had here? Thanks again.

@eduperez I see that only two files have been modified recently in /etc/config: ucitrack and luci_statistics. Here they are - do you see anything peculiar? Thanks!

root@LEDE-ArcherC7:/etc/config# cat ucitrack

config network
	option init 'network'
	list affects 'dhcp'
	list affects 'radvd'

config wireless
	list affects 'network'

config firewall
	option init 'firewall'
	list affects 'luci-splash'
	list affects 'qos'
	list affects 'miniupnpd'
	list affects 'sqm'

config olsr
	option init 'olsrd'

config dhcp
	option init 'dnsmasq'
	list affects 'odhcpd'

config odhcpd
	option init 'odhcpd'

config dropbear
	option init 'dropbear'

config httpd
	option init 'httpd'

config fstab
	option init 'fstab'

config qos
	option init 'qos'

config system
	option init 'led'
	list affects 'luci_statistics'

config luci_splash
	option init 'luci_splash'

config upnpd
	option init 'miniupnpd'

config ntpclient
	option init 'ntpclient'

config samba
	option init 'samba'

config tinyproxy
	option init 'tinyproxy'

config nlbwmon
	option init 'nlbwmon'

config sqm
	option init 'sqm'

config luci_statistics
	option init 'luci_statistics'

root@LEDE-ArcherC7:/etc/config# cat luci_statistics

config statistics 'collectd'
	option BaseDir '/var/run/collectd'
	option Include '/etc/collectd/conf.d'
	option PIDFile '/var/run/collectd.pid'
	option PluginDir '/usr/lib/collectd'
	option TypesDB '/usr/share/collectd/types.db'
	option Interval '30'
	option ReadThreads '2'

config statistics 'rrdtool'
	option default_timespan '1hour'
	option image_width '600'
	option image_path '/tmp/rrdimg'

config statistics 'collectd_rrdtool'
	option enable '1'
	option RRARows '100'
	option RRASingle '1'
	option RRATimespans '1hour 1day 1week 1month 1year'
	option DataDir '/opt/rrd'

config statistics 'collectd_csv'
	option enable '0'
	option StoreRates '0'
	option DataDir '/tmp'

config statistics 'collectd_email'
	option enable '0'
	option SocketFile '/var/run/collectd/email.sock'
	option SocketGroup 'nogroup'

config statistics 'collectd_logfile'
	option enable '0'
	option LogLevel 'notice'
	option File '/var/log/collectd.log'
	option Timestamp '1'

config statistics 'collectd_network'
	option enable '0'

config statistics 'collectd_unixsock'
	option enable '0'
	option SocketFile '/var/run/collectd/query.sock'
	option SocketGroup 'nogroup'

config statistics 'collectd_conntrack'
	option enable '0'

config statistics 'collectd_contextswitch'
	option enable '0'

config statistics 'collectd_cpu'
	option enable '1'

config statistics 'collectd_cpufreq'
	option enable '0'

config statistics 'collectd_df'
	option enable '0'
	option Devices '/dev/mtdblock/4'
	option MountPoints '/jffs'
	option FSTypes 'tmpfs'
	option IgnoreSelected '0'

config statistics 'collectd_disk'
	option enable '0'
	option Disks 'hda1 hdb'
	option IgnoreSelected '0'

config statistics 'collectd_dns'
	option enable '0'
	option Interfaces 'br-lan'
	option IgnoreSources '127.0.0.1'

config statistics 'collectd_entropy'
	option enable '0'

config statistics 'collectd_exec'
	option enable '0'

config statistics 'collectd_interface'
	option enable '1'
	option Interfaces 'br-lan'
	option IgnoreSelected '0'

config statistics 'collectd_iptables'
	option enable '0'

config collectd_iptables_match
	option table 'nat'
	option chain 'luci_fw_postrouting'
	option target 'MASQUERADE'
	option source '192.168.1.0/24'
	option outputif 'br-ff'
	option name 'LAN-Clients traffic'

config collectd_iptables_match
	option chain 'luci_fw_postrouting'
	option table 'nat'
	option target 'MASQUERADE'
	option source '10.61.230.0/24'
	option outputif 'br-ff'
	option name 'WLAN-Clients traffic'

config statistics 'collectd_irq'
	option enable '0'
	option Irqs '2 3 4 7'

config statistics 'collectd_iwinfo'
	option enable '1'

config statistics 'collectd_load'
	option enable '1'

config statistics 'collectd_memory'
	option enable '1'

config statistics 'collectd_netlink'
	option enable '0'
	option IgnoreSelected '0'
	option VerboseInterfaces 'br-lan'
	option QDiscs 'br-lan'

config statistics 'collectd_nut'
	option enable '0'
	option UPS 'myupsname'

config statistics 'collectd_olsrd'
	option enable '0'
	option Port '2006'
	option Host '127.0.0.1'

config statistics 'collectd_ping'
	option enable '0'
	option TTL '127'
	option Interval '30'
	option Hosts '127.0.0.1'

config statistics 'collectd_processes'
	option enable '0'
	option Processes 'uhttpd dnsmasq dropbear'

config statistics 'collectd_sensors'
	option enable '0'

config statistics 'collectd_splash_leases'
	option enable '0'

config statistics 'collectd_tcpconns'
	option enable '0'
	option ListeningPorts '0'
	option LocalPorts '22 80'

config statistics 'collectd_thermal'
	option enable '0'
	option IgnoreSelected '0'

config statistics 'collectd_uptime'
	option enable '1'

root@LEDE-ArcherC7:/etc/config#

Advice: Adjust permissions as needed for your usecase.

Nobody knows what the user wants to do with the freshly installed USB drive. Advice regarding required permissions should be given in the description of the application needing those permissions, not on the general USB drive installation page.

The advice for that was added to the LuCI statistics RRDtool config page in January 2017 with https://github.com/openwrt/luci/commit/eaafb4508c139b2aa8644c31c8349d5b25f2df8e

But that was added just to master (as 17.01 had already been branched off). The advice should likely be backported to 17.01 as it is naturally valid also there.

EDIT:
backported with https://github.com/openwrt/luci/commit/3b79e9eaa716a305ce214d882b4e9c01f1433b3a

Thanks for updating 17.01 to have this advice. I also updated the OpenWrt howto: https://wiki.openwrt.org/doc/howto/luci_app_statistics

@richb-hanover No, compared your files with mine, but could not find anything weird; I even tried using your files in my device, and "uci" did not complain at all.

Hmmm... Is there a way to "run luci against a config file" so that it will blurt out an error if there's a problem in the config? I could run it against all dozen or so files in /etc/config to see what generated that uci: Entry not found message. Thanks

You can run "uci show" to get a list of all parameters; it will scan all config files in alphabetical order, and show the error when it finds it. Or you can run "uci show secion", to scan a single section, and then find out the file where such section is stored.

If I remember correctly, the error message may also pop up in certain situations if you have non-uci files in /etc/config

Additionally, the error may pop up with package installation/removal if the handling of postinst and prerm (pre-removal) scripts of the package fails. If I remember right, there was bug in handling of those in conneciton with default-postinst and default-prerm, and that has been fixed at least in master, but not quite sure about 17.01.

Bingo! I did have an extra file in /etc/config - it was a list of all the luci packages that I had installed.

uci show indicated that the error appeared between the outputs of the network and rpcd files, and it was trivial to find the file. Thanks again.

1 Like

Great.
I ran into that same error a while ago, as I had stored some extra files in /etc/config to make them easily survive sysupgrade. I finally moved the files away and got rid of the error.

1 Like

I have a similar Luci Statics problem.

It was working until mid-April (I just noticed it) and writing to a 64GB USB stick in a WRT3200ACM. I am using the latest Davidc502 build (Lede SNAPSHOT r7093-4fdc6ca31b / LuCI Master (git-18.152.60731-18b5b06).

USB stick is set for 777 permissions cascaded down through the complete directory structure.

I can read the old data by the graphs from before mid-April but no new data is being feed to the RDD files.

My set-up for the luci-statistics config file is below. Can anyone see any errors in the setup or provide some help to get it working again?


config statistics 'collectd'
	option BaseDir '/var/run/collectd'
	option Include '/etc/collectd/conf.d'
	option PIDFile '/var/run/collectd.pid'
	option PluginDir '/usr/lib/collectd'
	option TypesDB '/usr/share/collectd/types.db'
	option Interval '30'
	option ReadThreads '2'

config statistics 'rrdtool'
	option default_timespan '1hour'
	option image_width '600'
	option image_path '/tmp/rrdimg'

config statistics 'collectd_rrdtool'
	option enable '1'
	option RRARows '100'
	option RRASingle '1'
	option RRATimespans '1hour 1day 1week 1month 1year'
	option DataDir '/mnt/sdb1/rrd'

config statistics 'collectd_csv'
	option enable '0'
	option StoreRates '0'
	option DataDir '/tmp'

config statistics 'collectd_email'
	option enable '0'
	option SocketFile '/var/run/collectd/email.sock'
	option SocketGroup 'nogroup'

config statistics 'collectd_logfile'
	option enable '0'
	option LogLevel 'notice'
	option File '/var/log/collectd.log'
	option Timestamp '1'

config statistics 'collectd_network'
	option enable '0'

config statistics 'collectd_unixsock'
	option enable '0'
	option SocketFile '/var/run/collectd/query.sock'
	option SocketGroup 'nogroup'

config statistics 'collectd_apcups'
	option enable '0'
	option Host 'localhost'
	option Port '3551'

config statistics 'collectd_conntrack'
	option enable '0'

config statistics 'collectd_contextswitch'
	option enable '0'

config statistics 'collectd_cpu'
	option enable '1'

config statistics 'collectd_cpufreq'
	option enable '1'

config statistics 'collectd_df'
	option enable '0'
	option Devices '/dev/mtdblock/4'
	option MountPoints '/jffs'
	option FSTypes 'tmpfs'
	option IgnoreSelected '0'

config statistics 'collectd_disk'
	option Disks 'hda1 hdb'
	option IgnoreSelected '0'
	option enable '1'

config statistics 'collectd_dns'
	option enable '0'
	option Interfaces 'br-lan'
	option IgnoreSources '127.0.0.1'

config statistics 'collectd_entropy'
	option enable '0'

config statistics 'collectd_exec'
	option enable '0'

config statistics 'collectd_interface'
	option enable '1'
	option Interfaces 'br-lan'
	option IgnoreSelected '0'

config statistics 'collectd_iptables'
	option enable '1'

config collectd_iptables_match
	option table 'nat'
	option target 'MASQUERADE'
	option source '192.168.1.0/24'
	option outputif 'br-ff'
	option name 'LAN-Clients traffic'

config collectd_iptables_match
	option table 'nat'
	option target 'MASQUERADE'
	option source '10.61.230.0/24'
	option outputif 'br-ff'
	option name 'WLAN-Clients traffic'

config statistics 'collectd_irq'
	option enable '0'
	option Irqs '2 3 4 7'

config statistics 'collectd_iwinfo'
	option enable '1'
	option IgnoreSelected '0'

config statistics 'collectd_load'
	option enable '1'

config statistics 'collectd_memory'
	option enable '1'

config statistics 'collectd_netlink'
	option IgnoreSelected '0'
	option VerboseInterfaces 'br-lan'
	option QDiscs 'br-lan'
	option enable '1'

config statistics 'collectd_nut'
	option enable '0'
	option UPS 'myupsname'

config statistics 'collectd_olsrd'
	option enable '0'
	option Port '2006'
	option Host '127.0.0.1'

config statistics 'collectd_ping'
	option enable '0'
	option TTL '127'
	option Interval '30'
	option Hosts '127.0.0.1'

config statistics 'collectd_processes'
	option enable '0'
	option Processes 'uhttpd dnsmasq dropbear'

config statistics 'collectd_sensors'
	option enable '1'

config statistics 'collectd_splash_leases'
	option enable '0'

config statistics 'collectd_tcpconns'
	option ListeningPorts '0'
	option LocalPorts '22 80'
	option enable '1'

config statistics 'collectd_thermal'
	option IgnoreSelected '0'
	option enable '1'

config statistics 'collectd_uptime'
	option enable '1'


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.