summaryrefslogtreecommitdiff
path: root/custom/uucp-mediaserver/scripts/queuestatus
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2018-04-05 22:05:05 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2018-04-05 22:05:05 +0200
commitaf359b71b000651812e1ee70638b480502eba0ec (patch)
tree8f246fa120b54c29f3bdf64e8e3b389ec5311851 /custom/uucp-mediaserver/scripts/queuestatus
parentfbc53fdb0e012524b1a22083d19a6928cc87870e (diff)
downloadnixos-af359b71b000651812e1ee70638b480502eba0ec.tar
nixos-af359b71b000651812e1ee70638b480502eba0ec.tar.gz
nixos-af359b71b000651812e1ee70638b480502eba0ec.tar.bz2
nixos-af359b71b000651812e1ee70638b480502eba0ec.tar.xz
nixos-af359b71b000651812e1ee70638b480502eba0ec.zip
media-server on odin
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