-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnar_get.cmd
More file actions
212 lines (185 loc) · 6.14 KB
/
nar_get.cmd
File metadata and controls
212 lines (185 loc) · 6.14 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
@If "%echoon%"=="" @echo off
If "%local%"=="" setlocal
set NOPAUSE=
set NOCLS=
If "%pauseon%"=="" set NOPAUSE=::
If not "%clson%"=="" set NOCLS=::
::=============================
::
:: nar_get.cmd is used to
:: Automatically start and grab
:: a nar file from an
:: EMC array to speed the time
:: to resolution of any type of
:: Problem.
::
:: Tested Platforms:
:: Windows Server 2003 SP1
:: Navicli ver 6.16.00.04.63
:: Flare 16 Patch 12
::
:: Aaron Baldie
:: EMC (c)
:: Version 0.1
:: 05/03/06
::=============================
::------------------------------
:: Setup logging files and paths
::------------------------------
set LOG="%~dp0%~n0.log"
::-------------------------------
:: Setup time and date stamp in logs
:: for each run of the batch file
::-------------------------------
ECHO ========================================== >> %LOG%
date /t >> %LOG%
time /t >> %LOG%
ECHO ------------- >> %LOG%
::--------------------------------
:: Start the applications that are
:: supposed to run
:: if pauseon has a value run with
:: pauses
::--------------------------------
:START
%NOPAUSE%pause
IF /i "%1"=="/h" GOTO :HELP
IF /i "%1"=="-h" GOTO :HELP
IF /I "%1"=="/help" GOTO :HELP
IF /I "%1"=="-help" GOTO :HELP
::--------------------------------
:: If there is a command line param
:: Go ahead and set it
::--------------------------------
set username=%1
set password=%2
set ip=%3
::--------------------------------
:: Check all of the user vars
::--------------------------------
If "%username%"=="" GOTO :NOUSERNAME
If "%password%"=="" GOTO :NOPASSWORD
If "%ip%"=="" GOTO :NOIP
::--------------------------------
:: Ah, the infamous date/time
:: loop to create stamped file
:: names
::--------------------------------
for /f "tokens=1-3 delims=/" %%x in ('date /t') do set year=%%z&& set day=%%y&& set month=%%x
set year=%year:~0,4%
set day=%day:~0,2%
set month=%month:~4,6%
for /f "tokens=1-2 delims=:" %%a in ('time /t') do set hour=%%a&& set min=%%b
set min=%min:~0,2%
::--------------------------------
:: Setup static env vars
::--------------------------------
if exist "c:\Program Files\emc\Navisphere CLI\navicli.exe" set NAVICLI="c:\Program Files\emc\Navisphere CLI\navicli.exe"
if exist "c:\Program Files (x86)\emc\Navisphere CLI\navicli.exe" set NAVICLI="c:\Program Files (x86)\emc\Navisphere CLI\navicli.exe"
if exist "c:\Program Files\emc\Navisphere CLI\archiveretrieve.jar set ARCHIVE="c:\Program Files\emc\Navisphere CLI\archiveretrieve.jar"
if exist "c:\Program Files (x86)\emc\Navisphere CLI\archiveretrieve.jar set ARCHIVE="c:\Program Files (x86)\emc\Navisphere CLI\archiveretrieve.jar"
::--------------------------------
:: Check for the navicli.exe file
:: If not present error out and
:: give the help screen
::--------------------------------
If not exist %NAVICLI% goto :NOCLI
::--------------------------------
:: Check for the navicli.exe file
:: If not present error out and
:: give the help screen
::--------------------------------
If not exist %ARCHIVE% goto :NOARCHIVE
:STARTCOLLECT
If not exist %ip% md %ip%
::--------------------------------
:: Give some feedback to the user
::--------------------------------
%NOCLS%cls
echo ******************************************
echo Collection Array info on %month% %day% %year% @ %hour%:%min%
%NAVICLI% -h %ip% getagent > %ip%_getagent.txt
echo reading Array info
for /f "tokens=3" %%x in ('findstr /s "Serial" %ip%_getagent.txt') do set serial=%%x
echo You are working on %serial%
for /f "tokens=3" %%x in ('findstr /s "Identifier" %ip%_getagent.txt') do set sp=%%x
echo The Current SP is %sp%
echo Collecting the nar file
java -jar %ARCHIVE% -User %username% -Password %password% -Address %ip% -File %year%_%month%_%day%-%hour%_%min%-%serial%_SP%sp%.nar -Location %ip%
echo Nar file %year%_%month%_%day%-%hour%_%min%-%serial%_SP%sp%.nar has been collected
echo The content of directory %ip% are:
echo =================================
dir /b %ip% | findstr /i "%serial%"
echo =================================
echo *******************************************
del %ip%_getagent.txt
::------------------------------------
:: Log everything
::------------------------------------
echo ****************************************** >> %LOG%
echo Collection Array info on %month% %day% %year% @ %hour%:%min% >> %LOG%
echo reading Array info >> %LOG%
echo You are working on %serial% >> %LOG%
echo The Current SP is %sp% >> %LOG%
echo Collecting the nar file >> %LOG%
echo Nar file %year%_%month%_%day%-%hour%_%min%-%serial%_SP%sp%.nar has been collected >> %LOG%
echo The content of directory %ip% are: >> %LOG%
echo ================================= >> %LOG%
dir /b %ip% | findstr /i "%serial%" >> %LOG%
echo ================================= >> %LOG%
echo ******************************************* >> %LOG%
echo Have a great day!!!
goto :END
::===========================Error Control Below Here=====================
:NOUSERNAME
echo -----------------------------
Echo You need to enter a username
echo %0 Username Password SP_IP_Address
echo -----------------------------
GOTO :END
:NOPASSWORD
echo -----------------------------
echo You need to enter a password
echo %0 Username Password SP_IP_Address
echo ------------------------------
GOTO :END
:NOIP
echo ------------------------------
echo You must have an ip address
echo to be able to collect the
echo log files
echo please enter an ip address
echo syntax is:
echo %0 Username Password SP_IP_Address
echo ------------------------------
goto :END
:NOCLI
echo -----------------------------
echo Navicli must be installed
echo on this machine in the default
echo directory:
echo
echo c:\Program Files\EMC\Navisphere CLI\
echo ------------------------------
GOTO :END
:NOARCHIVE
echo -----------------------------
echo archiveretrieve must be installed
echo on this machine in the default
echo directory:
echo
echo c:\Program Files\EMC\Navisphere CLI\
echo ------------------------------
GOTO :END
::=================================End Error Control========================
:HELP
echo ------------------------------
echo The command line syntax for
echo this app is:
echo %0 Username Password IP_Address
echo
echo ------------------------------
echo Help request only >> %LOG%
goto :END
:END
endlocal