diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-05 22:05:05 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-05 22:05:05 +0200 |
commit | af359b71b000651812e1ee70638b480502eba0ec (patch) | |
tree | 8f246fa120b54c29f3bdf64e8e3b389ec5311851 /custom/uucp-mediaserver/scripts/queuestatus | |
parent | fbc53fdb0e012524b1a22083d19a6928cc87870e (diff) | |
download | nixos-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-x | custom/uucp-mediaserver/scripts/queuestatus | 41 |
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 | |||
3 | typeset -a queue | ||
4 | queue=() | ||
5 | |||
6 | suffix=${${0:t}##*.} | ||
7 | uucpsize() { | ||
8 | command queuesize.${suffix} ${@} | ||
9 | } | ||
10 | mediaspace() { | ||
11 | cat @queueDir@/${suffix}.space | ||
12 | } | ||
13 | queuesize() { | ||
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 | |||
22 | queueTxt=$(grep -vE '^\s*$' @queueDir@/${suffix}.queue) | ||
23 | queue=(${(f)queueTxt}) | ||
24 | |||
25 | printf "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 | |||
30 | printf "Queue: %d\n Size: %s\n" \ | ||
31 | ${#queue} \ | ||
32 | $(queuesize | numfmt --to=iec-i --suffix=B) | ||
33 | |||
34 | printf "\n" | ||
35 | |||
36 | for 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} | ||
41 | done | ||