[gull] Truc et astuces: swift stat
felix
felix at f-hauri.ch
Wed Oct 30 16:30:12 CET 2024
Pour ceux qui utilisent swift (restic) et qui seraient d'accord que ça:
Account: AUTH_░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Containers: 2
Objects: 26627
Bytes: 457482129594
Containers in policy "policy-0": 2
Objects in policy "policy-0": 26627
Bytes in policy "policy-0": 457482129594
Meta Quota-Bytes: 1000000000000
Content-Type: text/plain; charset=utf-8
X-Timestamp: 1686835224.52240
Accept-Ranges: bytes
X-Account-Project-Domain-Id: _unknown
Vary: Accept
X-Trans-Id: tx░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
X-Openstack-Request-Id: tx░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Strict-Transport-Security: max-age=63072000
c'est moins joli que ça:
▕⠀⠀▏ 45.75% Account: AUTH_░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
▕⠀⠀▏ Containers: 2
▕⠀⠀▏ Objects: 26627
▕⠀⠀▏ Bytes: 457482129594
▕⠀⠀▏Containers in policy "policy-0": 2
▕⠀⠀▏ Objects in policy "policy-0": 26627
▕⠀⠀▏ Bytes in policy "policy-0": 457482129594
▕⠀⠀▏ Meta Quota-Bytes: 1000000000000
▕▂▂▏ Content-Type: text/plain; charset=utf-8
▕██▏ X-Timestamp: 1686835224.52240
▕██▏ Accept-Ranges: bytes
▕██▏ X-Account-Project-Domain-Id: _unknown
▕██▏ Vary: Accept
▕██▏ X-Trans-Id: tx░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
▕██▏ X-Openstack-Request-Id: tx░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
▕██▏ Strict-Transport-Security: max-age=63072000
Voici comment j'ajoute une barre de remplissage verticale et
modifie la première ligne pour ajouter l'état en poucents:
#!/bin/bash
source path/to/swiftEnvironment
swiftStat="$(swift stat)"
mapfile -t lines <<<"${swiftStat}"
policyBytes=${swiftStat#*Bytes in policy*: }
policyBytes=${policyBytes%%$'\n'*}
quotaBytes=${swiftStat#*Quota-Bytes: }
quotaBytes=${quotaBytes%%$'\n'*}
barHeight=$(( 8*${#lines[@]} * policyBytes / quotaBytes ))
prct=00$(( 100000 * policyBytes / quotaBytes ))
printf -v lines[0] '%6.2f%%%s' ${prct::-3}.${prct: -3} "${lines[0]:7}"
blockFull=$(( barHeight / 8 ))
emptyBlocks=$(( ( ${#lines[@]} * 8 - barHeight ) / 8 ))
lastBlock=$(( barHeight % 8 ? barHeight % 8 : 8))
for i in ${!lines[@]};do
printf '\U2595%b%b\U258F%s\n' \\U2$(( i < emptyBlocks ? 800 :
i == ${#lines[@]} - blockFull - 1 ? 580+lastBlock : 588 )){,} "${lines[i]}"
done
---
Restant à disposition pour tout commentaire ou éclairsissement.
--
Félix Hauri - <felix at f-hauri.ch> - http://www.f-hauri.ch
More information about the gull
mailing list