Created
January 16, 2023 15:48
-
-
Save alecs/cbdb2634b5f77a4fd4697f8191ca7c03 to your computer and use it in GitHub Desktop.
extract resources per OpenVZ running container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -f "/usr/sbin/vzlist" ]]; then | |
vzlist -a | awk '/^\s+[0-9]/ { print $1" "$5 }' | while read ct_id ct_host; do | |
echo -ne "${ct_host}\t"; | |
vzctl runscript ${ct_id} $0 | |
done | |
else | |
CPU=$(awk '/processor/ { cpu+=1 }; END { print cpu }' /proc/cpuinfo); | |
MEM=$(awk '/^MemTotal:/ { print $2/(1024*1024) }' /proc/meminfo); | |
DISK=$(df -k | awk '!/^tmp/ && !/^Filesystem/ {mp[$1"-"$2"-"$3]=$3 }; END {for (key in mp){ size+=mp[key]}; print size/(1024*1024)}'); | |
echo -ne "lxc\t${CPU}\t${MEM}\t${DISK}\r\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment