blob: 412c707408d6fcbbd601e223e1beaf93426f032c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!@zsh@/bin/zsh
lsof() { @lsof@/bin/lsof ${@} 2>/dev/null | tail -n +2}
ignoredFiles() {
cat <<EOF
^/usr/
^/lib
^/dev/
^pipe$
^/$
^/etc/
^/var/log/
EOF
}
slept=0
sleep=0.5
sleepTimeout=30
watched=false
while true; do
typeset -a files
files=()
used=$(lsof -c uucico -c uux | awk '{ $1=$2=$3=$4=$5=$6=$7=$8=""; print $0; }' | sed -r 's/^\s+//')
files=(${(f)used})
watched=false
for file (${files}); do
line=$(lsof ${file} | grep -E '^(uucico|uux) ')
line() { print ${line} }
print ${file} | grep -qEf =(ignoredFiles) && continue
[[ -z $(line) ]] && continue
fType=$(line | awk '{ print $5; }')
size=$(line | awk '{ print $7; }')
pid=$(line | awk '{ print $2; }')
fd=$(line | awk '{ print $4; }' | tr -dc '[:digit:]')
name=$(basename ${file} | awk -v len=19 '{ if (length($0) > len) print substr($0, 1, len-3) "..."; else print; }')
[[ ${fType} == "REG" ]] || continue
clear
@pv@/bin/pv -W -D 2 -i 0.5 -d ${pid}:${fd} -s ${size} -F "%r %a %p %e %I" -p -r -I -e -N ${name}
slept=0
watched=true
break
done
if $watched || [[ $slept -ge $(($sleepTimeout / $sleep)) ]]; then
printf "inotify (%s)\n" $(date +"%T")
@inotify@/bin/inotifywait -r -e access /var/spool/uucp &>/dev/null
slept=0
else
sleep 0.1
printf "."
slept=$(($slept + 1))
fi
done
|