From 64ae2fbe3ab578b3e27c260c702d9229b8398895 Mon Sep 17 00:00:00 2001 From: xf0r3m Date: Fri, 14 Jul 2023 17:37:50 +0200 Subject: [PATCH] =?utf8?q?W=C5=82=C4=85cznie=20do=20idle.sh=20get=5Fimage?= =?utf8?q?=5Fsize=20jako=20idle-size?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- get_image_size | 29 ----------------------------- idle.sh | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 29 deletions(-) delete mode 100755 get_image_size create mode 100644 idle.sh diff --git a/get_image_size b/get_image_size deleted file mode 100755 index 07ee8b3..0000000 --- a/get_image_size +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -filename=$1; - -function get_image_size() { - total=0; - size_suffix="MB"; - for remote in $(cut -d ";" -f 1 $1 | awk '{printf $1" "}'); do - image_size=$(/usr/bin/lxc image info $remote | grep '^Size' | awk '{printf $2" "}') - float_size=$(echo $image_size | grep -o '^[0-9*\.]*'); - total=$(echo "$total + $float_size" | bc -l); - echo "$remote = $image_size"; - done - csize_total=$(echo "$(cut -d ";" -f 2 $1 | grep '^[0-9\.]*' | awk '{printf $1" "}' | sed -s 's/ /+/g')0" | bc -l); - if [ $(echo $total | cut -d "." -f 1) -gt 1024 ]; then - total=$(echo "$total / 1024" | bc -l | cut -c 1-4); - csize_total=$(echo "$csize_total / 1024" | bc -l | cut -c 1-4); - size_suffix="GB"; - fi - echo "Total: ${total}${size_suffix}"; - echo "Aprox. container size: ${csize_total}${size_suffix}"; -} - -get_image_size $filename; -#ile będą wazyc kontenery: -#1. Trzeba pobrać jeden kontenr i sprawdzić jego rozmiar -#2. Następnie od rozmiaru kontenera odjąć romiar obrazu -#3. Ile procent wielkości obrazu wynosi różnica tych wartości -#4. Następnie dodać ten % do wielkości obrazu diff --git a/idle.sh b/idle.sh new file mode 100644 index 0000000..df6e3ab --- /dev/null +++ b/idle.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +export DATABASE=/usr/share/idle/database.csv; + +function idle-size() { + total=0; + size_suffix="MB"; + for remote in $(cut -d ";" -f 1 $DATABASE | awk '{printf $1" "}'); do + image_size=$(/usr/bin/lxc image info $remote | grep '^Size' | awk '{printf $2" "}') + float_size=$(echo $image_size | grep -o '^[0-9*\.]*'); + total=$(echo "$total + $float_size" | bc -l); + echo "$remote = $image_size"; + done + csize_total=$(echo "$(cut -d ";" -f 2 $DATABASE | grep -o '^[0-9\.]*' | awk '{printf $1" "}' | sed -s 's/ /+/g')0" | bc -l); + if [ $(echo $total | cut -d "." -f 1) -gt 1024 ]; then + total=$(echo "$total / 1024" | bc -l | cut -c 1-4); + csize_total=$(echo "$csize_total / 1024" | bc -l | cut -c 1-4); + size_suffix="GB"; + fi + echo "Total: ${total}${size_suffix}"; + echo "Aprox. containers size: ${csize_total}${size_suffix}"; +} + -- 2.39.5