From: Arne Fitzenreiter Date: Thu, 30 Jan 2025 09:23:10 +0000 (+0100) Subject: collectd: add more changes to the converter X-Git-Tag: v2.29-core192~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ebceac121adffbf8b8690101e4a50e3f4c1566e5;p=ipfire-2.x.git collectd: add more changes to the converter Signed-off-by: Arne Fitzenreiter --- diff --git a/config/backup/backup.pl b/config/backup/backup.pl index 51797c780..c64d56aee 100644 --- a/config/backup/backup.pl +++ b/config/backup/backup.pl @@ -263,15 +263,39 @@ restore_backup() { rm /var/lib/ipblocklist/SPAMHAUS_EDROP.conf fi + # The collectd directory structure was changed but not all changes + # are done by the official migration script generator + for i in $(seq 0 63); + do + if [ -e /var/log/rrd/collectd/localhost/cpufreq/cpufreq-$i.rrd ]; then + mkdir -p /var/log/rrd/collectd/localhost/cpufreq-$i + mv -f /var/log/rrd/collectd/localhost/cpufreq/cpufreq-$i.rrd \ + /var/log/rrd/collectd/localhost/cpufreq-$i/cpufreq.rrd + fi + done + if [ -e /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd ]; then + mv -f /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd \ + /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature.rrd + fi + # Create collectd 4.x to 5.x migration script from rrd contents, run the script that # was created and then remove the old interface directory if it is present as it will # be empty after the migration has been carried out. /var/ipfire/collectd-migrate-4-to-5.pl --indir /var/log/rrd/ > /tmp/rrd-migrate.sh sh /tmp/rrd-migrate.sh >/dev/null 2>&1 - rm -rf \ - /var/log/rrd/collectd/localhost/cpufreq \ - /var/log/rrd/collectd/localhost/interface \ - /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd + + # Run old collectd cleanup only if the interface dir exist to prevent cleanup of + # new devices if the user have reenabled it and restore a backup + if [ -d /var/log/rrd/collectd/localhost/interface ]; then + rm -rf \ + /var/log/rrd/collectd/localhost/cpufreq \ + /var/log/rrd/collectd/localhost/disk-loop* \ + /var/log/rrd/collectd/localhost/disk-sg* \ + /var/log/rrd/collectd/localhost/disk-sr* \ + /var/log/rrd/collectd/localhost/disk-ram* \ + /var/log/rrd/collectd/localhost/interface \ + /var/log/rrd/collectd/localhost/thermal-cooling_device* + fi # start collectd after restore /etc/rc.d/init.d/collectd start diff --git a/config/rootfiles/core/192/update.sh b/config/rootfiles/core/192/update.sh index 03bfc0bd6..858c27d2f 100644 --- a/config/rootfiles/core/192/update.sh +++ b/config/rootfiles/core/192/update.sh @@ -109,12 +109,28 @@ ldconfig # Create collectd 4.x to 5.x migration script from rrd contents, run the script that # was created and then remove the old interface directory if it is present as it will # be empty after the migration has been carried out. +for i in $(seq 0 63); +do + if [ -e /var/log/rrd/collectd/localhost/cpufreq/cpufreq-$i.rrd ]; then + mkdir -p /var/log/rrd/collectd/localhost/cpufreq-$i + mv -f /var/log/rrd/collectd/localhost/cpufreq/cpufreq-$i.rrd \ + /var/log/rrd/collectd/localhost/cpufreq-$i/cpufreq.rrd + fi +done +if [ -e /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd ]; then + mv -f /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd \ + /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature.rrd +fi /var/ipfire/collectd-migrate-4-to-5.pl --indir /var/log/rrd/ > /tmp/rrd-migrate.sh sh /tmp/rrd-migrate.sh >/dev/null 2>&1 rm -rvf \ /var/log/rrd/collectd/localhost/cpufreq \ + /var/log/rrd/collectd/localhost/disk-loop* \ + /var/log/rrd/collectd/localhost/disk-sg* \ + /var/log/rrd/collectd/localhost/disk-sr* \ + /var/log/rrd/collectd/localhost/disk-ram* \ /var/log/rrd/collectd/localhost/interface \ - /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd + /var/log/rrd/collectd/localhost/thermal-cooling_device* # Start services /etc/init.d/collectd start