Uci: Parse error executing luci statistics

Greetings,

I have 22.03.2 build running on a Orange PI R1 Plus built by another user:
OPR1_Plus 22.03.2

OPR1_plus forum post

Orang Pi R1 Plus

I am trying to run luci_statistics. When I try to run the following commands:

/etc/init.d/luci_statistics restart
/etc/init.d/luci_statistics reload

I receive this error:
env: can't execute 'ucode': No such file or directory

Googled a little, and found this command to find corrupted config files:
for x in /etc/config/*; do uci show "${x##*/}" >/dev/null || echo "$x is broken"; done

I have deleted any possible corrupt file until running the above command returns no more results. I am running out of ideas of what may be the cause.

Here is my luci_statistics config:

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 '/mnt/4GB/rrd'

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

config statistics 'collectd_csv'
	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 '1'
	option Forward '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'

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 Devices '/dev/mtdblock/4'
	option MountPoints '/jffs'
	option FSTypes 'tmpfs'
	option enable '1'
	option IgnoreSelected '1'

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

config statistics 'collectd_dns'
	option IgnoreSources '127.0.0.1'
	option enable '1'
	option Interfaces 'any'

config statistics 'collectd_entropy'
	option enable '0'

config statistics 'collectd_exec'

config statistics 'collectd_interface'
	option enable '1'
	option IgnoreSelected '1'

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 Irqs '2 3 4 7'

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

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'

config statistics 'collectd_nut'
	option UPS 'myupsname'

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

config statistics 'collectd_ping'
	option TTL '127'
	option Interval '30'
	option enable '1'
	option Hosts 'google.com 8.8.8.8 8.8.4.4'

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

config statistics 'collectd_sensors'
	option enable '1'

config statistics 'collectd_splash_leases'
	option enable '0'

config statistics 'collectd_tcpconns'
	option LocalPorts '22 80'
	option enable '1'
root@OP-R1_Plus:/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'
	list RRATimespans '1hour'
	list RRATimespans '1day'
	list RRATimespans '1week'
	list RRATimespans '1month'
	option DataDir '/mnt/4GB/rrd'

config statistics 'collectd_csv'
	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 '1'
	option Forward '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'

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 Devices '/dev/mtdblock/4'
	option MountPoints '/jffs'
	option FSTypes 'tmpfs'
	option enable '1'
	option IgnoreSelected '1'

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

config statistics 'collectd_dns'
	option IgnoreSources '127.0.0.1'
	option enable '1'
	option Interfaces 'any'

config statistics 'collectd_entropy'
	option enable '0'

config statistics 'collectd_exec'

config statistics 'collectd_interface'
	option enable '1'
	option IgnoreSelected '1'

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 Irqs '2 3 4 7'

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

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'

config statistics 'collectd_nut'
	option UPS 'myupsname'

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

config statistics 'collectd_ping'
	option TTL '127'
	option Interval '30'
	option enable '1'
	option Hosts 'google.com 8.8.8.8 8.8.4.4'

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

config statistics 'collectd_sensors'
	option enable '1'

config statistics 'collectd_splash_leases'
	option enable '0'

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

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

config statistics 'collectd_uptime'
	option enable '1'

config collectd_network_server
	option port '25826'
	option host 'monitoring.porta.codes'
	option enable '1'

config statistics 'collectd_chrony'

config statistics 'collectd_curl'

config statistics 'collectd_dhcpleases'

config statistics 'collectd_ipstatistics'

config statistics 'collectd_openvpn'

config statistics 'collectd_snmp6'

config statistics 'collectd_syslog'

logread has these errors

Tue Nov  8 10:30:21 2022 daemon.err collectd[4832]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Tue Nov  8 10:30:21 2022 daemon.err collectd[4832]: Configuration file /tmp/collectd.conf is empty.
Tue Nov  8 10:30:21 2022 daemon.err collectd[4832]: Error: Parsing the config file failed!
Tue Nov  8 10:30:26 2022 daemon.err collectd[4867]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Tue Nov  8 10:30:26 2022 daemon.err collectd[4867]: Configuration file /tmp/collectd.conf is empty.
Tue Nov  8 10:30:26 2022 daemon.err collectd[4867]: Error: Parsing the config file failed!
Tue Nov  8 10:30:31 2022 daemon.err collectd[4877]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Tue Nov  8 10:30:31 2022 daemon.err collectd[4877]: Configuration file /tmp/collectd.conf is empty.
Tue Nov  8 10:30:31 2022 daemon.err collectd[4877]: Error: Parsing the config file failed!
Tue Nov  8 10:30:36 2022 daemon.err collectd[4890]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Tue Nov  8 10:30:36 2022 daemon.err collectd[4890]: Configuration file /tmp/collectd.conf is empty.
Tue Nov  8 10:30:36 2022 daemon.err collectd[4890]: Error: Parsing the config file failed!
Tue Nov  8 10:30:41 2022 daemon.err collectd[4905]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Tue Nov  8 10:30:41 2022 daemon.err collectd[4905]: Configuration file /tmp/collectd.conf is empty.
Tue Nov  8 10:30:41 2022 daemon.err collectd[4905]: Error: Parsing the config file failed!

Tue Nov  8 10:49:35 2022 user.notice collectd[8239]: UCI config not found
Tue Nov  8 10:49:35 2022 daemon.err collectd[8291]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Tue Nov  8 10:49:35 2022 daemon.err collectd[8291]: Configuration file /tmp/collectd.conf is empty.
Tue Nov  8 10:49:35 2022 daemon.err collectd[8291]: Error: Parsing the config file failed!
root@OP-R1_Plus:/etc/config# 


Looks like some configuration requires the "ucode" utility, and it is not present in your device (perhaps a dependency issue); try installing the "ucode" package.

1 Like

opkg install ucode

Now I'm getting:

Wed Nov  9 10:11:35 2022 daemon.err collectd[16361]: Initialization complete, entering read-loop.

root@OP-R1_Plus:/# /etc/init.d/luci_statistics start
Syntax error: Unable to resolve path for module 'fs'
In line 16, byte 32:

 `import { lsdir, open } from 'fs';`
  Near here ----------------------^


Syntax error: Unable to resolve path for module 'uci'
In line 17, byte 28:

 `import { cursor } from 'uci';`
  Near here ------------------^

You need ucode-mod-fs as well.

2 Likes

Installed both modules:

Tried to restart luci_statistics and get this error:

root@OP-R1_Plus:/etc/init.d# /etc/init.d/luci_statistics restart
Syntax error: Unable to resolve path for module 'uci'
In line 17, byte 28:

 `import { cursor } from 'uci';`
  Near here ------------------^

logread:

Wed Nov  9 13:21:20 2022 daemon.err collectd[22482]: Configuration file /tmp/collectd.conf is empty.
Wed Nov  9 13:21:20 2022 daemon.err collectd[22482]: Error: Parsing the config file failed!
Wed Nov  9 13:21:25 2022 daemon.err collectd[22523]: Configuration file /tmp/collectd.conf is empty.
Wed Nov  9 13:21:25 2022 daemon.err collectd[22523]: Error: Parsing the config file failed!
Wed Nov  9 13:21:30 2022 daemon.err collectd[22536]: Configuration file /tmp/collectd.conf is empty.
Wed Nov  9 13:21:30 2022 daemon.err collectd[22536]: Error: Parsing the config file failed!
Wed Nov  9 13:21:35 2022 daemon.err collectd[22594]: Configuration file /tmp/collectd.conf is empty.
Wed Nov  9 13:21:35 2022 daemon.err collectd[22594]: Error: Parsing the config file failed!
Wed Nov  9 13:21:40 2022 daemon.err collectd[22767]: Configuration file /tmp/collectd.conf is empty.
Wed Nov  9 13:21:40 2022 daemon.err collectd[22767]: Error: Parsing the config file failed!
Wed Nov  9 13:21:45 2022 daemon.err collectd[22780]: Configuration file /tmp/collectd.conf is empty.
Wed Nov  9 13:21:45 2022 daemon.err collectd[22780]: Error: Parsing the config file failed!

ucode-mod-uci as well

2 Likes

As a final remark - only master/snapshot versions of luci-app-statistics require ucode. You mentioned "22.03.2 build" in the opening message, so you should use 22.03 packages of LuCI too, not snapshot ones.

2 Likes

Hello.. i'm having the same issue.. luci_statistics won't start and I'm using the latest snapshot build

no error when doing restart or reload for luci_statistics but I'm getting the following errors too:

Sun Dec  4 12:13:17 2022 daemon.err collectd[32582]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Sun Dec  4 12:13:17 2022 daemon.err collectd[32582]: Configuration file /tmp/collectd.conf is empty.
Sun Dec  4 12:13:17 2022 daemon.err collectd[32582]: Error: Parsing the config file failed!
Sun Dec  4 12:13:22 2022 daemon.err collectd[32584]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Sun Dec  4 12:13:22 2022 daemon.err collectd[32584]: Configuration file /tmp/collectd.conf is empty.
Sun Dec  4 12:13:22 2022 daemon.err collectd[32584]: Error: Parsing the config file failed!
Sun Dec  4 12:13:27 2022 daemon.err collectd[32587]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Sun Dec  4 12:13:27 2022 daemon.err collectd[32587]: Configuration file /tmp/collectd.conf is empty.
Sun Dec  4 12:13:27 2022 daemon.err collectd[32587]: Error: Parsing the config file failed!
Sun Dec  4 12:13:32 2022 daemon.err collectd[32589]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Sun Dec  4 12:13:32 2022 daemon.err collectd[32589]: Configuration file /tmp/collectd.conf is empty.
Sun Dec  4 12:13:32 2022 daemon.err collectd[32589]: Error: Parsing the config file failed!
Sun Dec  4 12:13:37 2022 daemon.err collectd[32591]: configfile: stat (/tmp/collectd.conf) failed: No such file or directory
Sun Dec  4 12:13:37 2022 daemon.err collectd[32591]: Configuration file /tmp/collectd.conf is empty.
Sun Dec  4 12:13:37 2022 daemon.err collectd[32591]: Error: Parsing the config file failed!
Sun Dec  4 12:13:37 2022 daemon.info procd: Instance collectd::instance1 s in a crash loop 6 crashes, 0 seconds since last crash

I've already checked the mentioned ucode packages but they are included in the snapshot build and are already installed.

Just in case somebody comes across this.. the issue is with the latest snapshot version of collectd. I've manually re-installed the collectd package from the release versions for 22.03 and everything worked again.

To be clear, do you mean that you upgraded packages and it caused an issue?

The packages are intended to use with the same branch that they are compiled for.
master packages should be used with master snapshot firmwares, while a release 22.03 branch firmware would need 22.03 packages.

What is your exact firmware?
and what is you Luci_statistics config?
(which statistics you are measuring? you mention ucode, so something regarding firewall / oiptables ?)

Does the error go away, if you disable just that one problematic stats module? (firewall, iptables, ucode, whatever)

As there has not been a general flood about complaint about luci statistics, it is likely something related to your build, installed stats packages and specific config.

I've updated my router using the latest master/snapshot (custom build) and that's when the issue started with collectd. Last time I did this was almost a year ago.

I thought the issue was with luci_statistics when I came across this thread. Only after doing a manual install using this for my router, that's when everything worked again.

1 Like

I'm using the master/snapshot for a custom build for my current main router Newifi D2 and all the packages in my build also uses the master/snapshot. Last time I updated my router was almost a year ago, the issue started after installing the updated build.

I only mentioned them because I read in one of the post here in the thread, it's needed for the snapshot builds of luci_statistics.

I'm only using a couple of stats, Processor, System Load, Memory, Interface, Wireless and Ping.

Again, I would like to re-iterate, everything started working again without changing any of the configs only after manually installing (via opkg --force-reinstall) the pre-built release version of collected in version 22.03.

My firmware is based on mipsel_24kc