Save luci-statistics/collectd across reboot

It must be anyone out there that wants to save longterm stats, therefore have done this? :slight_smile:
If not, please advice

Thank you

You need to add and setup permanent storage such as a USB flash drive.

You can then configure RRDtool output plugin in luci by going to Statistics > Setup then clicking the output plugins tab. You can then just change the rrd storage directory to one on the permanent storage.

1 Like

statistics - setup - output plugins - RRDtool tab and only change "Storage directory" ?

Yes. The only things which need saving are the .rrd files.

1 Like

and modifying that in luci would effectively change /etc/config/luci_statistics ? so i can take a backup before i change stuff :>

I would guess so.

How do i make a location "world readable"? Im new to linux world :frowning:

i know the chmod etc but whats the exact command pls? to make it "world-readable"

Create a share

thats a good idea thx

sorry for doublepost, creating a share in windows with "everyone" permission would qualify as "world readable"?

I meant install samba on the router.

Then create a share on the router itself for the directory you want to be world readable.

Ok, what i read from samba was to install samba on openwrt and connect to a networkshare from my windowsmachine, which can house the rrd files, maybe thats not possible?

See also this thread which is, in essence, about the same thing (saving stats across reboots, across updates, same difference.)

I wrote a backup/restore init.d script that may help (as an alternative for external storage.)

I have a lightweight approach, where I use scripts that save/restore the stats to flash. My goal is not to guarantee a full 100% of data, but to merely be able to see developments in the long run (monthly/yearly trends), e.g. memory consumption, CPU temp, etc. (As I run both master and 19.07 in my R7800 intermittently, there are differences in the data in any case.)

Saving collectd data every 30 seconds to flash, either router or USB stick, does not seem viable to be, so I keep the accumulating data quite normally in ramdisk /tmp/rrd.

As I store the stats on the router's flash, the data is neither reset-proof (firstboot clears overlay) nor sysupgrade-proof.

Cron runs the save script once per day to backup data against reboots.

I manually run the save / restore scripts in connection of a sysupgrade. I have configured the stats backup file to be carried along in sysupgrade.

And every few weeks I copy the backup file to external flash.

root@router1:~# cat /etc/
/etc/init.d/collectd stop
logger -t "LuCI statistics" Create backup archive
mkdir -p /etc/backup.stats
cd /tmp/rrd/$(uname -n)
tar c -zvf /etc/backup.stats/stats.tar.gz *
cp /etc/backup.stats/stats.tar.gz /etc/backup.stats/stats-$(date +%Y%m%dT%H%M).tar.gz
/etc/init.d/collectd start

root@router1:~# cat /etc/
/etc/init.d/collectd stop
logger -t "LuCI statistics" collectd stopped, stats being restored
mkdir -p /tmp/rrd/$(uname -n)
cd /tmp/rrd/$(uname -n)
tar x -zvf /etc/backup.stats/stats.tar.gz
/etc/init.d/collectd start

root@router1:~# cat /etc/crontabs/root
0 2 * * * /etc/

root@router1:~# cat /etc/sysupgrade.conf
## This file contains files and directories that should
## be preserved during an upgrade.
# /etc/example.conf
# /etc/openvpn/

This sounds like a really good idea, i am trying it out in a VM now.
The only thing that i dont really understand what it does is

root@router1:~# cat /etc/crontabs/root
0 2 * * * /etc/

Does this tell cron to run a scheduled task once per day? How would i set that up?
Thank you

Normal Linux cron stuff.
Like I said:

Just edit the root crontab file (normal text file, and can be done from LuCI), and make sure that the cron service runs.

Read wiki...

Thank you i think i got a good idea of how i want it now.
A question, would there be a way of running cronjobs, like the if a reboot command is issued?

Not with a cron job, that is usually done using a script in /etc/init.d ... my script is designed to do that.

FTR, it's not a competition, there are many ways to skin a cat.