summaryrefslogtreecommitdiff
path: root/monitor-uucp
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2018-04-14 14:17:56 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2018-04-14 14:17:56 +0200
commit3bb2f9a6caef07cd2d798fe52e340df524663a82 (patch)
tree4b7efc82afb7c02b6120a548b5578abdeecc9f84 /monitor-uucp
parent3fc89b51602f48938dcaa3d272fce130cd674093 (diff)
downloadutils-3bb2f9a6caef07cd2d798fe52e340df524663a82.tar
utils-3bb2f9a6caef07cd2d798fe52e340df524663a82.tar.gz
utils-3bb2f9a6caef07cd2d798fe52e340df524663a82.tar.bz2
utils-3bb2f9a6caef07cd2d798fe52e340df524663a82.tar.xz
utils-3bb2f9a6caef07cd2d798fe52e340df524663a82.zip
monitor-uucp
Diffstat (limited to 'monitor-uucp')
-rwxr-xr-xmonitor-uucp64
1 files changed, 64 insertions, 0 deletions
diff --git a/monitor-uucp b/monitor-uucp
new file mode 100755
index 0000000..412c707
--- /dev/null
+++ b/monitor-uucp
@@ -0,0 +1,64 @@
1#!@zsh@/bin/zsh
2
3lsof() { @lsof@/bin/lsof ${@} 2>/dev/null | tail -n +2}
4ignoredFiles() {
5 cat <<EOF
6^/usr/
7^/lib
8^/dev/
9^pipe$
10^/$
11^/etc/
12^/var/log/
13EOF
14}
15
16slept=0
17sleep=0.5
18sleepTimeout=30
19watched=false
20
21while true; do
22 typeset -a files
23 files=()
24
25 used=$(lsof -c uucico -c uux | awk '{ $1=$2=$3=$4=$5=$6=$7=$8=""; print $0; }' | sed -r 's/^\s+//')
26
27 files=(${(f)used})
28
29 watched=false
30
31 for file (${files}); do
32 line=$(lsof ${file} | grep -E '^(uucico|uux) ')
33 line() { print ${line} }
34
35 print ${file} | grep -qEf =(ignoredFiles) && continue
36 [[ -z $(line) ]] && continue
37
38 fType=$(line | awk '{ print $5; }')
39 size=$(line | awk '{ print $7; }')
40 pid=$(line | awk '{ print $2; }')
41 fd=$(line | awk '{ print $4; }' | tr -dc '[:digit:]')
42 name=$(basename ${file} | awk -v len=19 '{ if (length($0) > len) print substr($0, 1, len-3) "..."; else print; }')
43
44 [[ ${fType} == "REG" ]] || continue
45
46 clear
47 @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}
48
49 slept=0
50 watched=true
51
52 break
53 done
54
55 if $watched || [[ $slept -ge $(($sleepTimeout / $sleep)) ]]; then
56 printf "inotify (%s)\n" $(date +"%T")
57 @inotify@/bin/inotifywait -r -e access /var/spool/uucp &>/dev/null
58 slept=0
59 else
60 sleep 0.1
61 printf "."
62 slept=$(($slept + 1))
63 fi
64done