Created
December 12, 2017 22:29
-
-
Save ayumi/51cc68aea95c16195ff729ba5b085caa to your computer and use it in GitHub Desktop.
Shell script to calculate Xen aggregate VM CPU usage.
This file contains 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/sh | |
# Calculate aggregate VM CPU usage as integer percentage (eg 42). | |
# Denominator for awk division is 4 for 4 vCPUs -- change if needed. | |
xentop -b -d 1 -i 2 | tac | sed '/MAXMEM/,$d' | tr -s ' ' | sed -e 's/^[ \t]*//' | cut -d ' ' -f 4 | awk '{s+=$1} END {printf "%.0f", int(s/4)}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment