Optimized the script to work with empty rrd directories

Optimized the script to run without errors if empty directories in data/rrd are present.
This commit is contained in:
schadom 2020-11-27 09:55:21 +01:00 committed by GitHub
parent ca631c17f8
commit 3d0412f958
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,18 +5,16 @@
## my $newlinkname = 'NEWIDFROMKNOWNLINKSFILE'; ## my $newlinkname = 'NEWIDFROMKNOWNLINKSFILE';
## to reflect the ID in the known links file ## to reflect the ID in the known links file
A=`ls -1` A=`find . -type f -name '*.rrd' | sed -r 's|/[^/]+$||' |sort |uniq`
W=`pwd`
for i in $A ; do for i in $A ; do
echo ""
echo "dir: $i"
echo ""
cd $i cd $i
for f in *.rrd; do for f in *.rrd; do
echo "file: $f" echo "file: $i/$f"
mv $f $f.old mv $f $f.old
rrdtool dump $f.old | /data/as-stats/tools/add_ds_proc.pl | rrdtool restore - $f.new rrdtool dump $f.old | $W/add_ds_proc.pl | rrdtool restore - $f.new
mv $f.new $f mv $f.new $f
rm -f $f.old rm -f $f.old
done done