This repository has been archived on 2026-05-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
disco/client/bin/disco-fs-diff

81 lines
3.0 KiB
Plaintext
Raw Normal View History

#!/bin/bash
. /etc/disco/client.cfg
SCRIPTROOT=$(dirname $(readlink -f $0))
if [ "$NOOP" != "" ]; then
DISCOROOT=/var/disco/testfs/noop
else
DISCOROOT=/var/disco/testfs/real
fi
cd $DISCOROOT
rsync --checksum --times --perms --owner --group -ani ./scratchfs/ ./rootfs/ |\
grep -v ".unionfs.*/$" |\
sed s/"\.\/scratchfs"/""/ |\
sed s/"\.unionfs\/"/""/ |\
grep -v "./$" |\
sed s/"^[<>ch\.*]d"/"File: directory: "/ |\
sed s/"^[<>ch\.*]f"/"File: file: "/ |\
sed s/"^[<>ch\.*]L"/"File: symlink: "/ |\
sed s/"^[<>ch\.*]D"/"File: device: "/ |\
sed s/"^[<>ch\.*]S"/"File: special: "/ |\
sed s/": \([\.cstpoguax+]*\) \(.*\)$"/": \2 : \1"/ |\
sed s/"+++++++++$"/"Created"/ |\
sed s/" [\.cstpoguax]*$"/" Modified"/ |\
sed s/"_HIDDEN~ : Created"/" : Deleted"/ |\
sed s/"^\(.*\)\$"/"info: \1"/g |\
while read LINE
do
FNAME=$(echo $LINE | cut -d : -f 4 | sed s/"^ *"/""/ | sed s/" *$"/""/)
Added builtin performance metrics. Add REPORT=true to one of your disco dance runs to print the report at the end, or use 'disco report' to produce a report on the last disco dance; reports are cleared at the beginning of every disco dance. _internal diff is for the time taken to produce the filesystem diff _internal fetch_params is for how long it took to fetch all the client parameters Currently these performance numbers only account for about 50-70% of disco's activity, not sure how to report on the rest yet. Example output: report: _internal: diff report: time_real 1.15 : time_user 0.21 : time_sys 0.92 report: mem_avg 0 : mem_max 4816 : mem_faults_major 0 : mem_faults_minor 25400 report: io_fsin 0 : io_fsout 16 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: _internal: fetch_params report: time_real 1.14 : time_user 0.03 : time_sys 0.07 report: mem_avg 0 : mem_max 11152 : mem_faults_major 0 : mem_faults_minor 1674 report: io_fsin 0 : io_fsout 0 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: othermodule-3.2: fetch report: time_real 2.27 : time_user 0.06 : time_sys 0.13 report: mem_avg 0 : mem_max 11136 : mem_faults_major 0 : mem_faults_minor 2842 report: io_fsin 0 : io_fsout 24 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: othermodule-3.2: template report: etc/othermodule/stuff.cfg : report: time_real 0.53 : time_user 0.03 : time_sys 0.35 report: mem_avg 0 : mem_max 4656 : mem_faults_major 119 : mem_faults_minor 5086 report: io_fsin 25408 : io_fsout 16 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: testmodule-1.0: exec report: 00-hello.sh : report: time_real 0.29 : time_user 0.03 : time_sys 0.20 report: mem_avg 0 : mem_max 4592 : mem_faults_major 54 : mem_faults_minor 3871 report: io_fsin 10992 : io_fsout 8 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: 10-service_stop.sh : report: time_real 0.46 : time_user 0.03 : time_sys 0.32 report: mem_avg 0 : mem_max 4592 : mem_faults_major 110 : mem_faults_minor 4564 report: io_fsin 22328 : io_fsout 8 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: testmodule-1.0: fetch report: time_real 2.24 : time_user 0.05 : time_sys 0.13 report: mem_avg 0 : mem_max 11152 : mem_faults_major 0 : mem_faults_minor 2894 report: io_fsin 0 : io_fsout 24 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0
2012-08-17 20:46:57 -04:00
# ----- File modification/creation data
MODSTR=""
MD5_NEW=$(md5sum ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null| cut -d " " -f 1)
MD5_OLD=$(md5sum /${FNAME} 2>/dev/null| cut -d " " -f 1)
if [ "$MD5_NEW" != "$MD5_OLD" ]; then
MODSTR="$MODSTR md5=[$MD5_OLD => $MD5_NEW]"
fi
PERMS_NEW=$(stat --format "%G:%U %a" ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null)
PERMS_OLD=$(stat --format "%G:%U %a" /${FNAME} 2>/dev/null)
if [ "$PERMS_NEW" != "$PERMS_OLD" ]; then
MODSTR="$MODSTR perms=[$PERMS_OLD => $PERMS_NEW]"
fi
SELINUX_NEW=$(stat --format "%C" ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null)
SELINUX_OLD=$(stat --format "%C" /${FNAME} 2>/dev/null)
if [ "$SELINUX_NEW" != "$SELINUX_OLD" ]; then
MODSTR="$MODSTR selinux=[$SELINUX_OLD => $SELINUX_NEW]"
fi
TYPE_NEW=$(stat --format "%F" ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null)
TYPE_OLD=$(stat --format "%F" /${FNAME} 2>/dev/null)
if [ "$TYPE_NEW" != "$TYPE_OLD" ]; then
MODSTR="$MODSTR type=[$TYPE_OLD => $TYPE_NEW]"
fi
RAWMODE_NEW=$(stat --format "%f" ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null)
RAWMODE_OLD=$(stat --format "%f" /${FNAME} 2>/dev/null)
if [ "$RAWMODE_NEW" != "$RAWMODE_OLD" ]; then
MODSTR="$MODSTR mode=[$RAWMODE_OLD => $RAWMODE_NEW]"
fi
DEVICE_NEW=$(stat --format "%D" ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null)
DEVICE_OLD=$(stat --format "%D" /${FNAME} 2>/dev/null)
if [ "$DEVICE_NEW" != "$DEVICE_OLD" ]; then
MODSTR="$MODSTR device=[$DEVICE_OLD => $DEVICE_NEW]"
fi
if [ ! -d /${FNAME} ] && [ ! -d ${DISCOROOT}/scratchfs/${FNAME} ]; then
diff -N /${FNAME} ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null > /tmp/$$.diff
fi
Added builtin performance metrics. Add REPORT=true to one of your disco dance runs to print the report at the end, or use 'disco report' to produce a report on the last disco dance; reports are cleared at the beginning of every disco dance. _internal diff is for the time taken to produce the filesystem diff _internal fetch_params is for how long it took to fetch all the client parameters Currently these performance numbers only account for about 50-70% of disco's activity, not sure how to report on the rest yet. Example output: report: _internal: diff report: time_real 1.15 : time_user 0.21 : time_sys 0.92 report: mem_avg 0 : mem_max 4816 : mem_faults_major 0 : mem_faults_minor 25400 report: io_fsin 0 : io_fsout 16 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: _internal: fetch_params report: time_real 1.14 : time_user 0.03 : time_sys 0.07 report: mem_avg 0 : mem_max 11152 : mem_faults_major 0 : mem_faults_minor 1674 report: io_fsin 0 : io_fsout 0 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: othermodule-3.2: fetch report: time_real 2.27 : time_user 0.06 : time_sys 0.13 report: mem_avg 0 : mem_max 11136 : mem_faults_major 0 : mem_faults_minor 2842 report: io_fsin 0 : io_fsout 24 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: othermodule-3.2: template report: etc/othermodule/stuff.cfg : report: time_real 0.53 : time_user 0.03 : time_sys 0.35 report: mem_avg 0 : mem_max 4656 : mem_faults_major 119 : mem_faults_minor 5086 report: io_fsin 25408 : io_fsout 16 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: testmodule-1.0: exec report: 00-hello.sh : report: time_real 0.29 : time_user 0.03 : time_sys 0.20 report: mem_avg 0 : mem_max 4592 : mem_faults_major 54 : mem_faults_minor 3871 report: io_fsin 10992 : io_fsout 8 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: 10-service_stop.sh : report: time_real 0.46 : time_user 0.03 : time_sys 0.32 report: mem_avg 0 : mem_max 4592 : mem_faults_major 110 : mem_faults_minor 4564 report: io_fsin 22328 : io_fsout 8 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: testmodule-1.0: fetch report: time_real 2.24 : time_user 0.05 : time_sys 0.13 report: mem_avg 0 : mem_max 11152 : mem_faults_major 0 : mem_faults_minor 2894 report: io_fsin 0 : io_fsout 24 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0
2012-08-17 20:46:57 -04:00
# ------
echo $LINE |\
Added builtin performance metrics. Add REPORT=true to one of your disco dance runs to print the report at the end, or use 'disco report' to produce a report on the last disco dance; reports are cleared at the beginning of every disco dance. _internal diff is for the time taken to produce the filesystem diff _internal fetch_params is for how long it took to fetch all the client parameters Currently these performance numbers only account for about 50-70% of disco's activity, not sure how to report on the rest yet. Example output: report: _internal: diff report: time_real 1.15 : time_user 0.21 : time_sys 0.92 report: mem_avg 0 : mem_max 4816 : mem_faults_major 0 : mem_faults_minor 25400 report: io_fsin 0 : io_fsout 16 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: _internal: fetch_params report: time_real 1.14 : time_user 0.03 : time_sys 0.07 report: mem_avg 0 : mem_max 11152 : mem_faults_major 0 : mem_faults_minor 1674 report: io_fsin 0 : io_fsout 0 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: othermodule-3.2: fetch report: time_real 2.27 : time_user 0.06 : time_sys 0.13 report: mem_avg 0 : mem_max 11136 : mem_faults_major 0 : mem_faults_minor 2842 report: io_fsin 0 : io_fsout 24 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: othermodule-3.2: template report: etc/othermodule/stuff.cfg : report: time_real 0.53 : time_user 0.03 : time_sys 0.35 report: mem_avg 0 : mem_max 4656 : mem_faults_major 119 : mem_faults_minor 5086 report: io_fsin 25408 : io_fsout 16 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: testmodule-1.0: exec report: 00-hello.sh : report: time_real 0.29 : time_user 0.03 : time_sys 0.20 report: mem_avg 0 : mem_max 4592 : mem_faults_major 54 : mem_faults_minor 3871 report: io_fsin 10992 : io_fsout 8 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: 10-service_stop.sh : report: time_real 0.46 : time_user 0.03 : time_sys 0.32 report: mem_avg 0 : mem_max 4592 : mem_faults_major 110 : mem_faults_minor 4564 report: io_fsin 22328 : io_fsout 8 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0 report: testmodule-1.0: fetch report: time_real 2.24 : time_user 0.05 : time_sys 0.13 report: mem_avg 0 : mem_max 11152 : mem_faults_major 0 : mem_faults_minor 2894 report: io_fsin 0 : io_fsout 24 : io_sockin 0 : io_sockout 0 : io_signals 0 report: exit: 0
2012-08-17 20:46:57 -04:00
sed -e s/"Created$"/"Created : type=[${TYPE_NEW}] device=[${DEVICE_NEW}] mode=[${RAWMODE_NEW}] selinux=[${SELINUX_NEW}] md5=[${MD5_NEW}] perms=[${PERMS_NEW}]"/ |\
sed -e s/"Modified$"/"Modified :${MODSTR}"/ |\
sed s/"^\([a-z]*\): File: \([a-z]*\): "/"\1: File: \2: \/"/
if [ -f /tmp/$$.diff ]; then
cat /tmp/$$.diff
fi
rm -f /tmp/$$* 2>/dev/null
done
rm -f /tmp/$$*