diff options
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 | ||