forked from OpenXT/openxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
info_sr.sh
executable file
·140 lines (113 loc) · 3.04 KB
/
info_sr.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#! /bin/sh -e
get_cpu()
{
cat cpuinfo.log | sed -n -re 's/^model name.*: (.*)$/\1/p'
}
get_pci_class()
{
local class="$1"
cat lspci-mmnn.log | grep "\[${class}\]" | sed -re 's/"//g'
}
get_xc_build_info()
{
local info="$1"
cat xenclient.conf.log | sed -n -re "s/^${info} = (.*)$/\1/p"
}
get_txt_measured()
{
if grep -q 'TXT measured launch: TRUE' txt-stat.log
then
echo "true"
else
echo "false"
fi
}
get_wired_mac()
{
cat ifconfig.log | grep brbridged | sed -n -re 's/.* HWaddr ([0-9A-F:]*).*/\1/p'
}
get_asset()
{
f="/home/xc_assets/data/by_mac/`get_wired_mac`/ham"
[ -f "$f" ] && cat "$f"
}
get_dmi_info()
{
local table="$1"
local field="$2"
sed -n -re "/DMI type ${table},/,/^$/ s/.*${field}: (.*)$/\1/p" dmidecode.log
}
get_bios_info()
{
get_dmi_info "0" "$1"
}
get_machine_info()
{
get_dmi_info "1" "$1"
}
get_xenops_physinfo()
{
cat xenops_physinfo.log | sed -n -re "s/${1} = (.*)$/\1/p"
}
get_vm_node()
{
local db="$1"
local field="$2"
sed -n -re "s|.*\"${field}\": \"(.*)\".*|\1|p" "${db}"
}
display_vm()
{
local db="$1"
local format=""
printf "%s\n" "`get_vm_node "$db" "uuid"`"
format=" %-20s: %s\n"
for i in \
name hvm slot start_on_boot \
memory amt-pt hibernated \
gpu \
pv-addons-installed pv-addons-version portica-installed \
portica-enabled
do
printf "$format" "$i" "`get_vm_node "$db" "$i"`"
done
echo ""
}
tmp=`mktemp -d`
tar -C ${tmp} -xf "$1"
cd "${tmp}"/*
tar -xf vms.tar.bz2
tar -xf syslog.tar.bz2
format="%-40s %s\n"
printf "$format" "XenClient build" "`get_xc_build_info 'build'`"
printf "$format" "XenClient build date" "`get_xc_build_info 'build_date'`"
printf "$format" "XenClient build branch" "`get_xc_build_info 'build_branch'`"
printf "$format" "XenClient build tools" "`get_xc_build_info 'tools'`"
printf "$format" "XenClient release" "`get_xc_build_info 'release'`"
echo ""
printf "$format" "Asset" "`get_asset`"
printf "$format" "BIOS Vendor" "`get_bios_info 'Vendor'`"
printf "$format" "BIOS Version" "`get_bios_info 'Version'`"
printf "$format" "BIOS Release Date" "`get_bios_info 'Release Date'`"
echo ""
printf "$format" "Manufacturer" "`get_machine_info 'Manufacturer'`"
printf "$format" "Product" "`get_machine_info 'Product Name'`"
printf "$format" "Serial" "`get_machine_info 'Serial Number'`"
printf "$format" "Wake UP" "`get_machine_info 'Wake-up Type'`"
printf "$format" "SKU" "`get_machine_info 'SKU Number'`"
printf "$format" "UUID" "`get_machine_info 'UUID'`"
echo ""
printf "$format" "CPU" "`get_cpu`"
printf "$format" "CPUs" "`get_xenops_physinfo 'nr_cpus'`"
printf "$format" "RAM" "`get_xenops_physinfo 'total_pages'`"
printf "$format" "GPU" "`get_pci_class 0300`"
printf "$format" "Wireless Card" "`get_pci_class 0280`"
printf "$format" "Wired Card" "`get_pci_class 0200`"
printf "$format" "Wired Mac" "`get_wired_mac`"
printf "$format" "TXT measured" "`get_txt_measured`"
echo ""
for i in *.db
do
display_vm "$i"
done
cd /tmp
rm -rf "${tmp}"