-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollect_vm_state.sh
More file actions
executable file
·49 lines (39 loc) · 1.23 KB
/
collect_vm_state.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.23 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
function print_info_each_cpu {
COMMAND=$1
for i in `seq 0 $LAST_CPU_ID`; do
echo "CPU #"${i}":"
virsh qemu-monitor-command $VM_NAME \
'{ "execute": "human-monitor-command", ' \
'"arguments": {' \
'"cpu-index":'${i}','\
'"command-line": "info '${COMMAND}'" } }' \
| sed 's/\\r\\n/\n/g' | sed 's/\\t/\t/g'
done
}
function print_header {
HEADER=$1
HEADER=`echo $1 | tr '[:lower:]' '[:upper:]'`
echo "===== ${HEADER} STATE ====="
}
function print_info {
COMMAND=$1
print_header $COMMAND
virsh qemu-monitor-command $VM_NAME --hmp info $COMMAND
}
VM_NAME=$1
if [[ -z $VM_NAME ]]; then
echo "Collect information about VM via qemu-monitor interface"
echo "Usage:$0 <vm_name>"
exit
fi
CPUS=`virsh qemu-monitor-command $VM_NAME --hmp info cpus | wc -l`
CPUS=$((CPUS-2))
LAST_CPU_ID=$((CPUS-1))
echo "$VM_NAME cpu number: $CPUS"
print_info "cpus"
for INFO_TYPE in "registers" "lapic"; do
print_header $INFO_TYPE
print_info_each_cpu $INFO_TYPE
done
print_info "ioapic"