Unsolved
This post is more than 5 years old
24 Posts
1
5316
Use VPLEXCLI to show only luns with "error" status
Trying to use the vplexcli to show me only logical-units with a status of ERROR.
For example; I can run this:
VPlexcli:/clusters/cluster-1/storage-elements/storage-arrays/EMC-CLARiiON-APMxxx/logical-units> ll
VPD83T3:6006016036c02c00dcad6c248c2ee211 error APM00121002844.SPA APM00121002844.SPB none implicit-explicit
VPD83T3:6006016036c02c00de6830d2dd08e211 ok APM00121002844.SPB APM00121002844.SPA both 0x001e000000000000 implicit-explicit
VPD83T3:6006016036c02c00e066a740f907e211 ok APM00121002844.SPA APM00121002844.SPB both 0x000e000000000000 implicit-explicit
How can I narrow this down to only list luns with the error status?
Intech1
57 Posts
1
December 8th, 2012 17:00
Login to the service account on the management server. Create a script called sv-errors (using vi) in the service home directory and paste the following in the file.
#!/usr/bin/expect -f
# connect to vplexcli
spawn vplexcli
# Look for login prompt
expect -re "Name:"
# Send login
send "service\r"
# Look for password prompt
expect -re "Password:"
# Send password - your password if different
send "Mi@Dim7T\r"
expect -re "VPlexcli:/> "
send "storage-volume summary \r"
expect -re "VPlexcli:/> "
expect eof
Set the permissions to executable (chmod 755 sv-errors).
Then run your new command (make sure your logged into the management server not the vplexcli)
./sv-errors | grep error
Note where I placed the command storage-volume summary. You can place any command or sequence of commands using my simple example.
AaronAnderson1
24 Posts
0
December 8th, 2012 19:00
The output of "storage-volume summary" is this
VPlexcli:/> storage-volume summary
Storage-Volume Summary (no tier)
---------------------- --------------------
Health out-of-date 0
storage-volumes 238
unhealthy 0
Vendor DGC 196
XIOTECH 42
Use meta-data 4
used 234
Capacity total 100T
So your command sequence won't give any output.
Intech1
57 Posts
0
December 9th, 2012 06:00
Are you running metro or geo? Try using storage-volume summary -c cluster-1 (or 2) if running metro or geo. You could also sub in your command in my script. The key is the expect script. By using the script from the management server you are able to take advantage of the Linux utilities, like grep and awk to manipulate the output of the vplexcli commands.
Sent from my iPad
AaronAnderson1
24 Posts
1
December 10th, 2012 06:00
Here's what I came up with:
In a file named lun-errors.sh
#!/usr/bin/expect -f
# connect to vplexcli
spawn vplexcli
# Look for login prompt
expect -re "Name:"
# Send login
send "service\r"
# Look for password prompt
expect -re "Password:"
# Send password
send "password\r"
expect -re "VPlexcli:/> "
send "ll /clusters/cluster-1/storage-elements/storage-arrays/EMC-CLARiiON-APM00121002844/logical-units/\r"
expect -re "VPlexcli:/> "
expect eof
Then I massage that to my liking with:
service@ManagementServer:~> ./2844-errors.sh | grep error | sed 's/ *\ error.*//' | sed 's/^/storage-volume forget -c cluster-1 -i /'
storage-volume forget -c cluster-1 -i VPD83T3:6006016036c02c003e7c4a8cd708e211
storage-volume forget -c cluster-1 -i VPD83T3:6006016036c02c00406ff7b6dd08e211
storage-volume forget -c cluster-1 -i VPD83T3:6006016036c02c0076c694afdd08e211
This get's me a script I can copy/paste after I carefully review the results.
Intech1
57 Posts
0
December 10th, 2012 07:00
Excellent. Expect scripting is the way to go.
Steve
Sent from my iPad
Anonymous
5 Practitioner
5 Practitioner
•
274.2K Posts
1
November 7th, 2013 09:00
Thanks for a very helpful post.
On executing a script similar to the above I received an error:
couldn't execute "vplexcli": no such file or directory
while executing
"spawn vplexcli"
(file "./listvol.sh" line 5)
This was solved (at least for me) by placing the full path to vplexcli.
spawn /usr/local/bin/vplexcli
This may be useful for someone in the future.
Cheers,
Alan.
Andrew-F
27 Posts
0
November 8th, 2013 07:00
doing this via expect is ok, but a better way is to use simple API calls. Though the API might be a little intimidating to a person experienced in shell scripting, it can be used to execute VPLEX CLI commands and feed the output to something for further processing.
I use curl as it is simple to implement once you know how. Below is an example introducing the topic for those of us not used to object programming with Perl or other languages that the API is better suited for.
First for simplicity, create a file called curl.cfg in your home dir. Inside that will be some basic curl options and API headers containing the authentication necessary to execute the API calls. Since the file contains authentication information, the permissions on the file should be so that only the appropriate user(s) can read or copy the file.
curl.cfg:
# curl config file specify with -K or --config
#
# --verbose -k -H "Username:service" -H "Password:Mi@Dim7T"
#--verbose
#
# -i display response headers
-i
-k
-H "Username:username"
-H "Password:password"
#-H "Accept: application/json;format=1;prettyprint=1"
# command timeout
-m 180
# supress session timer info
-s
Then to execute the listing and grep for error:
"ls -l /clusters/cluster-1/storage-elements/storage-arrays/EMC-CLARiiON-APM000834XXXXX/logical-units"
try:
curl -K curl.cfg -g -d '{"args":"-l /clusters/cluster-1/storage-elements/storage-arrays/EMC-CLARiiON-APM000834XXXXX/logical-units"}' -X POST https://vplex_mgmt_ip/vplex/ls | awk -F\" '
{
if ( /custom-data/ ) {
array_size=split($4,array,"\\\\n") # split on \n chars (not newline char)
for (outline = 1; outline <= array_size; outline++) {
gsub("\\\\t","\t",array[outline]) # replace \t chars with real tab char
if ( match (array[outline],SEARCH) > 0 ) { printf "%s\n",array[outline] }
}
printf "\n"
}
} ' SEARCH="error"
Note that the command is in the URL but the rest of the command line is in the POST data {"args":"-l ..."}.
Also, for compound commands like "export storage-view addvirtualvolume" would all be in the URL but the spaces would be replaced with "+" as in "export+storage-view+addvirtualvolume"
The output from successful commands is located in the custom-data response field. However, it appears as all one line with "\n" and "\t" strings signifying where newline and tab characters should be. The awk script replaces the strings for both tab and newline characters with the real character and then prints only the line which contains the search string specified at the closing of the awk script.
Note that you can use regex in the search string instead of just a string. For example you could look for specific storage volumes that contained a range of hex in it by changing "error" to "[ABC]38298" which could match A38298,B38298,or C38298. And if you weren't certain about case you could do "[AaBbCc]38298" Or, specify ranges like "[A-D]3829[3-8]"
I hope you find this useful.