Last active
March 5, 2019 17:30
-
-
Save dosaboy/d180399325b189e85249db7d67178cb4 to your computer and use it in GitHub Desktop.
nova_compute_stats_check.sh
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 -eu | |
| # | |
| # Origin: https://gist.github.com/dosaboy/d180399325b189e85249db7d67178cb4 | |
| # | |
| # Authors: | |
| # - [email protected] | |
| # - [email protected] | |
| # | |
| # Description: | |
| # Check compute host stats | |
| # | |
| # Avaialble Keys: https://github.com/openstack/nova/blob/master/nova/compute/stats.py | |
| # | |
| stat_key=${1:-"failed_builds"} | |
| passwd=`sudo egrep "mysql.+nova$" /etc/nova/nova.conf| sed "s,.*mysql://nova:\(.*\)@\(.*\)/nova$,\1,"` | |
| host=`sudo egrep "mysql.+nova$" /etc/nova/nova.conf| sed "s,.*mysql://nova:\(.*\)@\(.*\)/nova$,\2,"` | |
| readarray info<<<"`mysql -BN -h$host -unova -p$passwd nova -e'select host, stats from compute_nodes;'`" | |
| echo "${#info[@]}" | |
| ( | |
| for i in "${info[@]}"; do | |
| host=`echo "$i"| sed -r 's/([[:alnum:]]+)\s+.+/\1/g'` | |
| stats=`echo "$i"| sed -r 's/([[:alnum:]]+)\s+(.+)/\2/g'` | |
| result=`echo "$stats"| jq -r .$stat_key` | |
| echo "Host $host has $result $stat_key" | |
| done | |
| ) | column -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment