-
Notifications
You must be signed in to change notification settings - Fork 9
/
report-node-resources.sh
executable file
·26 lines (24 loc) · 1.5 KB
/
report-node-resources.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
#
# Collect data from an OpenStack Hypervisor node
#
### Remote script
output="openstack.data"
echo "=== ip_addr" > $output
ip addr show scope global eth2.519 | grep inet | awk '{ print $2 }' | grep '/32' | cut -d/ -f1 | sort >> $output
echo "=== iptables_float-snat" >> $output
iptables -n -t nat -L nova-network-float-snat | egrep -v 'Chain|target' | awk '{ print $6 }' | grep -v '^$' | cut -d: -f2 | sort -u >> $output
echo "=== iptables_OUTPUT" >> $output
iptables -n -t nat -L nova-network-OUTPUT | egrep -v 'Chain|target' | awk '{ print $5 }' | grep -v '^$' | sort -u >> $output
echo "=== iptables_PREROUTING" >> $output
iptables -n -t nat -L nova-network-PREROUTING | egrep -v 'Chain|target' | awk '{ print $5 }' | egrep -v '^169\.|^$' | sort -u >> $output
echo "=== iptables_POSTROUTING" >> $output
iptables -n -t nat -L nova-network-POSTROUTING | egrep -v 'Chain|target' | grep ^SNAT | awk '{ print $8 }' | grep -v '^$' | cut -d: -f2 | sort -u >> $output
echo "=== virsh_list" >> $output
virsh list --all --name | sed '/^$/ d' >> $output
echo "=== virsh_nwfilter" >> $output
virsh nwfilter-list | grep nova-instance- | awk '{ print $2 }' | cut -d- -f3-5 >> $output
#ls -1 /etc/libvirt/nwfilter/nova-instance-* | cut -d- -f3-4
# memory & cpu allocated
# total_vcpu=$(grep vcpu /var/lib/nova/instances/*-*/libvirt.xml | cut -d\> -f2 | cut -d\< -f1 | awk '{sum+=$1}END{print sum}')
# total_mem=$(grep memory /var/lib/nova/instances/*-*/libvirt.xml | cut -d\> -f2 | cut -d\< -f1 | awk '{sum+=$1}END{print sum}')