-
Notifications
You must be signed in to change notification settings - Fork 0
/
hgst_report2.8.bat
303 lines (207 loc) · 9.55 KB
/
hgst_report2.8.bat
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
@echo off
REM Author: CTS GSS (Nitin Kushwah)
REM JBOD Log gathering for Windows
REM V2.8
set VERSION=2.8
REM History: v2.8 10th Sept 2018: Additional search strings, and log collection
REM History: v2.7 20th July 2018: fixed bug for multiple ESM logs collection
REM History: v2.6 18th May 2018: removed makecab as it fails under some conditions.
REM History: v2.5 10th May 2018: Added Megaraid storcli commands
REM History: v2.4 21st Mar 2018: Clean directory structure, 60 days of windows logs
REM History: v2.3 19th Mar 2018: Added support for SMART
REM History: v2.2 19th Mar 2018: Added support for hgst_diag_tool and hdm
REM History: 16th Mar 2018: Added system information logs,msinfo(driver), suppressed error for page EA
REM History: 14th Mar 2018: Script can now collect logs from more than 2 ESMs
REM History: 14th Mar 2018: Added windows system and application log collection
REM History:8th Mar 2018: added automatic scanning the ESM ID
REM History:8th Mar 2018: added E6 raw page collection
echo Script Version : %VERSION%
::If 3rd param is blank then scan for ESMs
IF [%3]==[] GOTO Magicscan
::If 3rd param is present then set all param without scanning
IF NOT [%3]==[] (
set ESMA=%1
set ESMB=%2
set DIR=%3
GOTO Run
)
:Magicscan
setlocal enabledelayedexpansion
set COUNT=0
echo "Scannning ESMs....."
for /f "tokens=1" %%i in ('sg_scan -s ^| findstr -i "4U60 4U102 2u 4u peak madonna scaleapex H4102 H4060 enclosu 2U24 1ES0"') do (
set "INPUT=%%i"
set /A COUNT=!COUNT!+1
set "INPUT=!INPUT:DATA:=!"
set VAR[!COUNT!]=!INPUT!
call echo ESM !COUNT! = %%VAR[!COUNT!]%%
)
REM IF [%1]==[] GOTO Syntax
REM set ESMA="%VAR[1]%"
REM IF NOT DEFINED VAR[2] (SET VAR[2]=NA)
REM set ESMB="%VAR[2]%"
REM set DIR=%1
set DIR="%1\logs_%COMPUTERNAME%_%DATE:~-4%%DATE:~4,2%%DATE:~7,2%_%time:~-11,2%%time:~-8,2%%time:~-5,2%"
:Run
WHERE sg_scan >nul 2>nul
IF %ERRORLEVEL% EQU 0 GOTO ses
IF %ERRORLEVEL% EQU 1 GOTO Missing
:ses
WHERE sg_ses >nul 2>nul
IF %ERRORLEVEL% EQU 0 GOTO inq
IF %ERRORLEVEL% EQU 1 GOTO Missing
:inq
WHERE sg_inq >nul 2>nul
IF %ERRORLEVEL% EQU 0 GOTO Gather
IF %ERRORLEVEL% EQU 1 GOTO Missing
:Gather
mkdir %DIR%\winlogs
echo Script Version: %VERSION% > %DIR%\ver.txt
echo. >> %DIR%\ver.txt
echo sg_scan: >> %DIR%\ver.txt
sg_scan -V 2>> %DIR%\ver.txt
echo. >> %DIR%\ver.txt
echo sg_ses: >> %DIR%\ver.txt
sg_ses -V 2>> %DIR%\ver.txt
mkdir %DIR%\esm
sg_scan -s >> %DIR%\esm\SG_SCAN.txt
echo ______________________ >> %DIR%\esm\SG_SCAN.txt
for /l %%n in (1,1,%COUNT%) do (
echo ESM%%n !VAR[%%n]! >> %DIR%\esm\SG_SCAN.txt
)
::Collecting System Information
echo Collecting System Information.....
ECHO.
ECHO.
ECHO If log capture appears hang please press Enter key....
ECHO.
ECHO.
systeminfo >%DIR%\winlogs\systeminfo.txt
msinfo32 /report %DIR%\winlogs\msinfo.txt
echo Collecting System Events.....
wevtutil qe System /q:"*[System[TimeCreated[timediff(@SystemTime) <= 7776000000]]]" /rd:True /f:text >%DIR%\winlogs\system_event.txt
echo Collecting Application Events......
wevtutil qe Application /q:"*[System[TimeCreated[timediff(@SystemTime) <= 7776000000]]]" /rd:True /f:text >%DIR%\winlogs\Application_events.txt
WHERE hgst_diag_tool.exe >nul 2>nul
IF %ERRORLEVEL% EQU 0 GOTO HGSTtools
IF %ERRORLEVEL% EQU 1 GOTO NoHGSTtools
:HGSTtools
echo Collecting HGST diag logs......
mkdir %DIR%\hgstlogs
for /l %%n in (1,1,%COUNT%) do (
hgst_diag_tool.exe -d !VAR[%%n]! -n
move diag_dump_*.dat %DIR%\hgstlogs\
)
:NoHGSTtools
WHERE smartctl.exe >nul 2>nul
IF %ERRORLEVEL% EQU 0 GOTO SMART
IF %ERRORLEVEL% EQU 1 GOTO NoSMART
:SMART
echo Collecting SMART logs......
mkdir %DIR%\smartlogs
smartctl.exe --scan > %DIR%\smartlogs\smart_scan.txt
for /f "tokens=1" %%i in ('smartctl.exe --scan') do (
echo %%i >> %DIR%\smartlogs\smart_health.txt
smartctl.exe -H %%i >> %DIR%\smartlogs\smart_health.txt
smartctl.exe -x %%i >> %DIR%\smartlogs\smart_extended.txt
)
:NoSMART
WHERE hdm.exe >nul 2>nul
IF %ERRORLEVEL% EQU 0 GOTO HDM
IF %ERRORLEVEL% EQU 1 GOTO NoHDM
:HDM
echo Collecting HDM logs......
mkdir %DIR%\hdm
hdm generate-report >> %DIR%\hdm\hdm_report.txt
:NoHDM
WHERE storcli.exe >nul 2>nul
IF %ERRORLEVEL% EQU 0 GOTO Storcli
IF %ERRORLEVEL% EQU 1 GOTO NoStorcli
:Storcli
echo Collecting Storcli logs......
mkdir %DIR%\storcli
storcli /c0/eAll/sAll show all>> %DIR%\storcli\c0_eAll_sAll.txt
storcli /c0 show all >> %DIR%\storcli\show_all.txt
storcli /c0 show termlog >> %DIR%\storcli\termlog.txt
storcli /c0 show events filter=warning,critical,fatal >>%DIR%\storcli\events.txt 2>nul
REM collecting only 500 info events else script fails to compress it (possibly a bug)
storcli /c0 show events type=latest=500 filter=info >>%DIR%\storcli\events_info.txt 2>nul
:NoStorcli
for /l %%n in (1,1,%COUNT%) do (
mkdir %DIR%\ESM%%n
echo Collecting logs for : ESM%%n !VAR[%%n]! ......
sg_ses !VAR[%%n]! -p0x0 >> %DIR%\ESM%%n\page_00h.txt
sg_ses !VAR[%%n]! -p0x1 >> %DIR%\ESM%%n\page_01h.txt
sg_ses !VAR[%%n]! -p0x2 >> %DIR%\ESM%%n\page_02h.txt
sg_ses !VAR[%%n]! -p0x3 >> %DIR%\ESM%%n\page_03h.txt
sg_ses !VAR[%%n]! -p0x5 >> %DIR%\ESM%%n\page_05h.txt
sg_ses !VAR[%%n]! -p0x7 >> %DIR%\ESM%%n\page_07h.txt
sg_ses !VAR[%%n]! -p0xA >> %DIR%\ESM%%n\page_0Ah.txt
sg_ses !VAR[%%n]! -p0xEA >> %DIR%\ESM%%n\page_EAh.txt 2>nul
sg_ses !VAR[%%n]! -jj >> %DIR%\ESM%%n\join.txt
sg_inq !VAR[%%n]! >> %DIR%\ESM%%n\inq.txt
sg_inq !VAR[%%n]! -p0x83 >> %DIR%\ESM%%n\inq_83h.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 00 01 00 00 00 00 20 10 00 2>> %DIR%\ESM%%n\console_log.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 01 01 00 00 00 00 20 10 00 2>> %DIR%\ESM%%n\console_log.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 02 01 00 00 00 00 20 10 00 2>> %DIR%\ESM%%n\console_log.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 00 02 00 00 00 00 20 10 00 2>> %DIR%\ESM%%n\crashlog_primary.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 00 02 00 20 00 00 20 10 00 2>> %DIR%\ESM%%n\crashlog_primary.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 00 02 00 40 00 00 20 10 00 2>> %DIR%\ESM%%n\crashlog_primary.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 01 02 00 00 00 00 20 10 00 2>> %DIR%\ESM%%n\crashlog_secondary1.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 01 02 00 20 00 00 20 10 00 2>> %DIR%\ESM%%n\crashlog_secondary1.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 01 02 00 40 00 00 20 10 00 2>> %DIR%\ESM%%n\crashlog_secondary1.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 02 02 00 00 00 00 20 10 00 2>> %DIR%\ESM%%n\crashlog_secondary2.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 02 02 00 20 00 00 20 10 00 2>> %DIR%\ESM%%n\crashlog_secondary2.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 02 02 00 40 00 00 20 10 00 2>> %DIR%\ESM%%n\crashlog_secondary2.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 00 03 00 00 00 00 20 10 00 2>> %DIR%\ESM%%n\eventlog_primary.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 00 03 00 20 00 00 20 10 00 2>> %DIR%\ESM%%n\eventlog_primary.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 00 03 00 40 00 00 20 10 00 2>> %DIR%\ESM%%n\eventlog_primary.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 01 03 00 00 00 00 20 10 00 2>> %DIR%\ESM%%n\eventlog_secondary1.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 01 03 00 20 00 00 20 10 00 2>> %DIR%\ESM%%n\eventlog_secondary1.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 01 03 00 40 00 00 20 10 00 2>> %DIR%\ESM%%n\eventlog_secondary1.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 02 03 00 00 00 00 20 10 00 2>> %DIR%\ESM%%n\eventlog_secondary2.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 02 03 00 20 00 00 20 10 00 2>> %DIR%\ESM%%n\eventlog_secondary2.txt
sg_raw !VAR[%%n]! -r 0x4000 E6 02 03 00 40 00 00 20 10 00 2>> %DIR%\ESM%%n\eventlog_secondary2.txt
REM senddiag
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,69,32,63,20,73,63,61,6e
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\i2c_scan.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,73,68,6f,77,20,69,6f
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\show_io.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,73,68,6f,77,20,65,6e,63
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\show_enc.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,73,68,6f,77,20,73,65,6e,73,6f,72
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\show_sensor.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,73,68,6f,77,20,64,75,61,6c
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\show_dua.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,73,68,6f,77,20,64,72,69,76,65,73
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\show_drives.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,73,68,6f,77,20,70,68,79,73
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\show_phys.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,73,65,63,31,20,73,68,6f,77,20,70,68,79,73
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\sec1_show_phys.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,73,65,63,32,20,73,68,6f,77,20,70,68,79,73
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\sec2_show_phys.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,70,68,79,69,6e,66,6f
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\phyinfo.txt
sg_senddiag !VAR[%%n]! --pf --raw=EC,00,00,FF,00,00,00,00,70,68,79,69,6e,66,6f,20,62,75,66,66,65,72
sg_ses !VAR[%%n]! -p0xec >> %DIR%\ESM%%n\phyinfo_buffer.txt
)
cd %DIR%
GOTO Package
:Syntax
ECHO.
ECHO Please specify the destination for logs files.
ECHO.
GOTO End
:Package
ECHO.
ECHO.
ECHO Provide the logs %DIR% created to support for further analysis.
ECHO.
GOTO End
:Missing
ECHO.
ECHO One or more of the required utilities are not recognized as Internal or External commands - 'sg_scan' 'sg_ses' 'sg_inq'
ECHO.
GOTO End
:End