summaryrefslogtreecommitdiff
path: root/custom/uucp-mediaserver/scripts/queuestatus
diff options
context:
space:
mode:
Diffstat (limited to 'custom/uucp-mediaserver/scripts/queuestatus')
-rwxr-xr-xcustom/uucp-mediaserver/scripts/queuestatus41
1 files changed, 41 insertions, 0 deletions
diff --git a/custom/uucp-mediaserver/scripts/queuestatus b/custom/uucp-mediaserver/scripts/queuestatus
new file mode 100755
index 00000000..babacfea
--- /dev/null
+++ b/custom/uucp-mediaserver/scripts/queuestatus
@@ -0,0 +1,41 @@
1#!@zsh@/bin/zsh
2
3typeset -a queue
4queue=()
5
6suffix=${${0:t}##*.}
7uucpsize() {
8 command queuesize.${suffix} ${@}
9}
10mediaspace() {
11 cat @queueDir@/${suffix}.space
12}
13queuesize() {
14 local sum=0
15 for file (${queue}); do
16 local size=$(stat -c "%s" "${file}") || continue
17 sum=$((sum + size))
18 done
19 printf "%d" ${sum}
20}
21
22queueTxt=$(grep -vE '^\s*$' @queueDir@/${suffix}.queue)
23queue=(${(f)queueTxt})
24
25printf "Space: %s\n Reported: %s\n UUCP queue size: %s\n" \
26 $(numfmt --to=iec-i --suffix=B -- $(($(mediaspace) - $(uucpsize)))) \
27 $(mediaspace | numfmt --to=iec-i --suffix=B) \
28 $(uucpsize | numfmt --to=iec-i --suffix=B)
29
30printf "Queue: %d\n Size: %s\n" \
31 ${#queue} \
32 $(queuesize | numfmt --to=iec-i --suffix=B)
33
34printf "\n"
35
36for file (${queue}); do
37 size() {
38 stat -c "%s" "${file}" | numfmt --to=iec-i --suffix=B
39 }
40 printf "%6s %s\n" $(size || printf "N/A") ${file:t}
41done