+++ /dev/null
-#!/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
--- /dev/null
+#!/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}";
+}
+