diff options
author | Jamie McClelland <jm@mayfirst.org> | 2010-01-04 11:23:35 -0500 |
---|---|---|
committer | Jamie McClelland <jm@mayfirst.org> | 2010-01-04 11:23:35 -0500 |
commit | 20432e8cb24528b006c174cf598559f268ffe035 (patch) | |
tree | b4b7a481b8f74cac699fea9aedbf90ef7b1fb4fd | |
parent | cac5ef58b78338591be29da5c536208cf1a39842 (diff) | |
download | kvm-manager-20432e8cb24528b006c174cf598559f268ffe035.tar.gz kvm-manager-20432e8cb24528b006c174cf598559f268ffe035.tar.bz2 |
adding first version of kvm-status script that displays information
about existing virtual servers.
-rwxr-xr-x | kvm-status | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/kvm-status b/kvm-status new file mode 100755 index 0000000..08445cc --- /dev/null +++ b/kvm-status @@ -0,0 +1,28 @@ +#!/bin/bash + +dir=/etc/sv/kvm + +function convert_ram { + display_ram= + ram=$(echo "$1" | tr [:upper:] [:lower:]) + label=$(echo $ram| tr -d "[0-9]+") + value=${ram%$label} + if [ -z "$label" ] || [ "$label" = "mb" ]; then + display_ram=$value + else + display_ram=$(( $value * 1024 )) + fi +} + +temp=$(mktemp) +echo "SERVER RAM" > "$temp" +total_ram=0 +for foo in $(ls $dir); do + ram=$(cat $dir/$foo/env/RAM) + convert_ram "$ram" + echo "$foo $display_ram" >> "$temp" + total_ram=$(( $total_ram + $display_ram )) +done +echo "TOTAL $total_ram" >> "$temp" +column -t "$temp" +rm "$temp" |