2021-01-20 15:34:54 +08:00
|
|
|
#!/bin/bash
|
|
|
|
. /root/openrc
|
|
|
|
echo "Openstack usage generated on $(date)"
|
2021-01-20 16:08:30 +08:00
|
|
|
|
|
|
|
echo -en "\nNumber of active VMs: "
|
2021-01-20 15:34:54 +08:00
|
|
|
mysql nova -Nse "select count(1) from instances where vm_state = 'active'"
|
|
|
|
|
2021-01-20 16:08:30 +08:00
|
|
|
echo -en "\n***Usage summary***\n"
|
2021-02-23 16:23:35 +08:00
|
|
|
openstack usage list -f csv | column -t -s, | tr -d \"
|
2021-01-20 16:08:30 +08:00
|
|
|
|
|
|
|
echo -en "\n***Ceph info***\n"
|
|
|
|
ceph df | grep -v "0 B"
|
|
|
|
ceph osd df tree | grep host | awk '{print $NF,$(NF-4)"% Used"}'
|
|
|
|
|
|
|
|
echo -en "\n***Detail host usage***\n"
|
2021-01-20 15:34:54 +08:00
|
|
|
echo -en "Host CPU% Memory%\n" | column -t
|
|
|
|
openstack host list -fvalue -c 'Host Name' | grep compute | sort | while read h; do openstack host show $h -fcsv | egrep '(total|now)' | tr -d \" | paste - - | awk -F, '{print $1, $7/$3*100"%", $8/$4*100"%"}'; done | column -t
|
|
|
|
|
2021-01-20 16:08:30 +08:00
|
|
|
echo -en "\n\nGenerated by /root/openstack-simple-report.sh from $(hostname)"
|
2021-01-20 15:34:54 +08:00
|
|
|
|