This repository was archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsystem_information
More file actions
executable file
·273 lines (245 loc) · 6.88 KB
/
system_information
File metadata and controls
executable file
·273 lines (245 loc) · 6.88 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#!/bin/bash
# To get all information about the system
#set -x
#Execute scrip as ROOT User
#Descompress with tar -jxvf system_information.tar.bz2
#Created by Jorge Valderrama
TEMP="/tmp"
COMPRESS="system_information/"
DIR="/tmp/system_information"
FILE="$(basename $0).$RANDOM.txt"
FILE1="nova-manage-services-list.$RANDOM.txt"
STACKOPS_HEAD="stackops-head"
CONTROLLER="controller"
COMPUTE="compute"
RESOURCE=""
function create_system_information()
{
> $FILE
{
echo "****1. HARDWARE INFORMATION****"
echo ""
echo "**1.1 Hardware Lister in XML**"
echo ""
lshw -xml
echo ""
echo "**1.2 System UUID**"
echo ""
cat /sys/class/dmi/id/product_uuid
echo ""
echo "****2. SYSTEM INFORMATION****"
echo ""
echo "**2.1 Unix Name**"
echo ""
uname -a
echo ""
echo "**2.2 Change User Password Expiry Information: User ROOT**"
echo ""
chage -l root
echo ""
echo "**2.3 Change User Password Expiry Information: User STACKOPS**"
echo ""
chage -l stackops
echo ""
echo "****3. DISK INFORMATION****"
echo ""
echo "**3.1 Disk Free**"
echo ""
df -h
echo ""
echo "**3.2 Mount Point**"
echo ""
mount
echo ""
echo "**3.3 Fixed Disk (Disk Partitioning)**"
echo ""
fdisk -l
echo ""
echo "****4. NETWORK INFORMATION****"
echo ""
echo "**4.1 Interface Configuration**"
echo ""
ifconfig -a
echo "**4.2 Network Interface Configuration Information**"
echo ""
cat /etc/network/interfaces
echo ""
} > $FILE
echo "General System Information Generated"
}
function create_stackops_head_information_log()
{
cp -r /var/log/stackops-head .
cp -r /var/log/installer .
cp /var/log/syslog .
cp /var/log/dmesg .
echo "Stackops Head Log Information Generated: stackop-head, installer syslog and dmesg"
}
function create_stackops_head_information_conf()
{
cp -r /var/lib/stackops-head/etc .
cp -r /var/lib/stackops-head/conf .
echo "Stackops Head Configuration Information Generated: stackops-head/etc and stackops-head/conf"
}
function create_stackops_head_backups()
{
pass=$(cat /root/.mysql_pw)
head-manage db backup root $pass stackopshead > stackop-head.sql
if [ $? -gt 0 ]; then
echo "ERROR: At the moment to generate Stackop Head database backup"
else
echo "Stackops Head Database Backup Information Generated"
fi
}
function create_controller_compute_information_log()
{
cp -r /var/log/installer .
cp -r /var/log/stackops .
cp -r /var/log/nova .
cp /var/log/syslog .
cp /var/log/dmesg .
if [ "${RESOURCE:0:10}" == $CONTROLLER ]; then
cp -r /var/log/glance .
echo "Controller Log Information Generated: installer, stackops, nova, glance, syslog and dmesg"
else
echo "Compute Log Information Generated: installer, stackops, nova, syslog and dmesg"
fi
}
function create_controller_compute_information_conf()
{
cp -r /var/lib/nova .
echo "$RESOURCE Configuration Information Generated: nova"
}
function create_controller_backups()
{
pass=$(grep sql_connection /etc/nova/nova.conf | cut -d @ -f 1 | cut -d : -f 3)
mysqldump --user=root --password=$pass -B nova > nova.sql
if [ $? -gt 0 ]; then
echo "ERROR: At the moment to generate Nova database backup"
else
echo "Nova $RESOURCE Database Backup Information Generated"
fi
mysqldump --user=root --password=$pass -B glance > glance.sql
if [ $? -gt 0 ]; then
echo "ERROR: At the moment to generate Glance database backups"
else
echo "Glance $RESOURCE Database Backup Information Generated"
fi
}
function structure_directories()
{
if [ -d "$DIR_MAIN" ]; then
cd $DIR_MAIN
else
mkdir $DIR_MAIN
cd $DIR_MAIN
fi
if [ -d "$DIR_LOG" ]; then
cd $DIR_LOG
if [ "$RESOURCE" == $STACKOPS_HEAD ]; then
echo "Resource identified as Stackops-Head"
create_stackops_head_information_log
fi
if [ "${RESOURCE:0:10}" == $CONTROLLER ]; then
echo "Resource identified as Controller"
create_controller_compute_information_log
fi
if [ "${RESOURCE:0:7}" == $COMPUTE ]; then
echo "Resource identified as Compute"
create_controller_compute_information_log
fi
else
mkdir $DIR_LOG
cd $DIR_LOG
if [ "$RESOURCE" == $STACKOPS_HEAD ]; then
echo "Resource identified as Stackops-Head"
create_stackops_head_information_log
fi
if [ "${RESOURCE:0:10}" == $CONTROLLER ]; then
echo "Resource identified as Controller"
create_controller_compute_information_log
fi
if [ "${RESOURCE:0:7}" == $COMPUTE ]; then
echo "Resource identified as Compute"
create_controller_compute_information_log
fi
fi
if [ -d "$DIR_CONF" ]; then
cd $DIR_CONF
if [ "$RESOURCE" == $STACKOPS_HEAD ]; then
create_stackops_head_information_conf
fi
if [ "${RESOURCE:0:10}" == $CONTROLLER ]; then
create_controller_compute_information_conf
fi
if [ "${RESOURCE:0:7}" == $COMPUTE ]; then
create_controller_compute_information_conf
fi
else
mkdir $DIR_CONF
cd $DIR_CONF
if [ "$RESOURCE" == $STACKOPS_HEAD ]; then
create_stackops_head_information_conf
fi
if [ "${RESOURCE:0:10}" == $CONTROLLER ]; then
create_controller_compute_information_conf
fi
if [ "{$RESOURCE:0:7}" == $COMPUTE ]; then
create_controller_compute_information_conf
fi
fi
if [ -d "$DIR_BACKUPS" ]; then
cd $DIR_BACKUPS
if [ "$RESOURCE" == $STACKOPS_HEAD ]; then
create_stackops_head_backups
fi
if [ "${RESOURCE:0:10}" == $CONTROLLER ]; then
create_controller_backups
fi
else
mkdir $DIR_BACKUPS
cd $DIR_BACKUPS
if [ "$RESOURCE" == $STACKOPS_HEAD ]; then
create_stackops_head_backups
fi
if [ "${RESOURCE:0:10}" == $CONTROLLER ]; then
create_controller_backups
fi
fi
}
function check_resource()
{
RESOURCE=$(uname -n)
DIR_MAIN="/tmp/system_information/$RESOURCE"
DIR_LOG="/tmp/system_information/$RESOURCE/logs"
DIR_CONF="/tmp/system_information/$RESOURCE/configuration"
DIR_BACKUPS="/tmp/system_information/$RESOURCE/backups"
structure_directories
if [ "${RESOURCE:0:10}" == $CONTROLLER ]; then
cd $DIR_LOG
> $FILE1
nova-manage service list > $FILE1
fi
compress_directory
}
function compress_directory(){
if [ -d "$TEMP" ]; then
cd $TEMP
tar -jcf "system_information.tar.bz2" "$COMPRESS"
rm -rf $COMPRESS
echo "Finished with compressing directories. Ready to send to Stackops and solve your petitions. Located in /tmp"
else
echo "ERROR: At the moment to generate the compress directory, /tmp directory does not exists"
fi
}
if [ -d "$DIR" ]; then
cd $DIR
rm system_information.*
create_system_information
check_resource
else
mkdir $DIR
cd $DIR
create_system_information
check_resource
fi