Some tips for using the SVC and Storwize V7000 Command Line Interface

The SVC and Storwize V7000 offers a command line interface that you access via SSH.   You start your favorite SSH client (such as PuTTY or Mindterm) and then logon as admin or as your own user-id.   Right now to do this you need to generate a private/public key pair, although with release 6.3 (which will be available November 2011), you will be able to logon via SSH using just a user-id and password.

Having logged on there are three categories of commands you can issue:

svcinfo:    Informational commands that let you examine your configuration.
svctask:   Task commands that let you change your configuration.
satask:     Service commands that are only used in specific circumstances.

There are several CLI usability features that I routinely find users are not aware of, so I thought I would share some of them here:

1)  Listing all possible commands

If you cannot remember a command, here is a simple trick to list them all.
Issue one of the following commands:

svcinfo -h  or  svcinfo -?
svctask -h  or  svctask -?

You can also type either svcinfo or svctask and then hit the tab key twice to get a full listing.  With svctask you will need to type y to list them all, as per the example shown below:

IBM_2076:STG_V7000:admin>svctask   (HIT TAB twice!)
Display all 139 possibilities? (y or n)  y

2)  Getting help on a particular command

Having found the command you want, issue that command with either -? or -h to get help information.   For instance:

svctask mkvdisk -?
or
svctask mkvdisk -h

You will be shown the same help information that you can find in the Infocenter, including examples of syntax.

3)  Drop the svctask and svcinfo prefixes

In release 6.2 of the SVC and Storwize V7000 firmware, the requirement to prefix a command with svcinfo or svctask has been removed.  However I tend to keep using them because I write a lot of example commands for clients and I cannot be sure which version of firmware they are running.

4)  Use the shell

When we SSH to the SVC or Storwize V7000 we are connecting to a Linux operating system using a special restricted shell.   Some of the common Unix commands don’t work (such as ls or grep or awk), but any commands that are provided by the shell itself, will work, such as while, if, read, pipe and echo.

We can use this to construct some really clever commands.

For instance creating volume copies is very popular, but the default copy rate is rather slow (50, which equals 2 MBps).   It is not unusual for end users to speed up the background copy and then forget to slow it down when they are finished.   So I wrote two commands to help me out.   Firstly I run a command to display the copy rate of every volume.   Ideally I should see 50 alongside each volume.  However I often find that some volumes are set to higher numbers, such as  the maximum value of 100 (which is 64 MBps).

svcinfo lsvdisk -nohdr |while read id name IO_group_id;do svcinfo lsvdisk $id |while read id value;do if [[ $id == "sync_rate" ]];then echo $value"  "$name;fi;done;done

Lets break down this command.  The structure looks like this:

  1. We start with svcinfo lsvdisk -nohdr.   This gives us a list of every VDisk in column format with no header information.
  2. We pipe the output of that lsvdisk command to while read.  This reads the output one line at a time and lets us work with that output.  We read the first three columns of output and label the data in the first column id, the second column name and the third column IO_Group.  I find we need to label at least three columns.   We could read extra columns if we wanted to, but all I want is the VDisk id and name.
  3. For every line of data we issue an lsvdisk command against each listed VDisk using the VDisk id.  This output is not in column format so we need to do something different here.
  4. We now examine the output of the lsvdisk command for each VDisk by piping the output to while read.  Since each line contains a descriptor and a value, we label them id and value.   We use if to look for a line that starts with sync_rate.
  5. When we find the sync_rate for a VDisk we print the value of the sync_rate and the VDisk name.  We are done for this VDisk.
  6. We now examine the next VDisk and again look for the sync_rate for that VDisk.
  7. Once we have examined every VDisk, we are done.

I then run the following command which sets the copy rate for every volume to the default value of 50 (2 MBps):

svcinfo lsvdisk -nohdr |while read id name IO_group_id;do svctask chvdisk -syncrate 50 $id;done

Clearly you could edit this second command to change the copy rate to any value between 0 and 100.  In each case you just paste the entire command in, and hit Enter.

Lets break down this command.  The structure looks like this:

  1. We start with svcinfo lsvdisk -nohdr.   This gives us a list of every VDisk in column format with no header information.
  2. We pipe the output of that lsvdisk command to while read.  This reads the output one line at a time and lets us work with that output.  We read the data in the first three columns of output and label the data in the first column id, the second column name and the third column IO_Group.  I find we need to label at least three columns.   We could read extra columns if we wanted to, but all I want is the VDisk id.
  3. For every line of data we read, we do the following command:
    svctask chvdisk -syncrate 50 $id.   Since we labelled the first column of output from the lsvdisk command as id, and that column contains VDisk IDs, we are going to issue this command against every VDisk that got listed.
  4. Once we have run the chvdisk command against every VDisk listed, we are done.

There are lots of possible clever combinations and I will list a few more in upcoming posts.

I have also been getting lots of requests to write a post about updating drive firmware, so expect something on that very soon.

Advertisements

About Anthony Vandewerdt

I am an IT Professional who lives and works in Melbourne Australia. This blog is totally my own work. It does not represent the views of any corporation. Constructive and useful comments are very very welcome.
This entry was posted in IBM Storage, Storwize V7000, SVC and tagged , , . Bookmark the permalink.

11 Responses to Some tips for using the SVC and Storwize V7000 Command Line Interface

  1. Paul Rizio says:

    thanks for this helpful information

  2. Pingback: Some tips for using the SVC and Storwize V7000 Command Line Interface « Storage CH Blog

  3. Phil H says:

    Hi Anthony,
    You can also use the -a switch on the read command which will put the line into an array. So, for example, using on of your scripts:

    svcinfo lsvdisk -nohdr |while read -a vdisk
    do
    svctask chvdisk -syncrate 50 ${vdisk[0]}
    done

    I’ve set up a community on Developerworks which talks about this sort of stuff. It was formerly on W3 so it’s pretty new still, but eveyone’s free to join and contribute or use what’s there already.

    https://www.ibm.com/developerworks/mydeveloperworks/groups/service/html/communityview?communityUuid=ce5f40da-a393-4569-b283-4810e0aa31ce

  4. Chris H says:

    Good article. Along the same lines, I’ve got a collection of “miniscripts” similar to yours which I’ve used on the SVC. It includes a very simple but handy replacement for grep:

    http://www.db94.net/wtf/pmwiki.php?n=Main.HandySVCMiniScripts

    and

    http://www.db94.net/wtf/pmwiki.php?n=Main.SVCMiniscriptStorage

    • Chris, your website is AWESOME. Reading your page was a fantastic discovery, thanks so much for sharing. I wrote this blog post because I have met many clients who did not realize the power of the CLI shell if you put your mind to it, so seeing your page is really cool. I will write another post soon and mention your page in it.

      • Chris H says:

        Thanks! I can’t take credit for the last one with the pivot tables, either, that’s Dan Rumney, who is a genius with this stuff. I showed the basics to him one day, and the next day he had this pivot table craziness. I was really impressed!

  5. jim g says:

    Does anyone know how to get to Chris H. website, I tried but the link doesn’t appear to be working anylonger.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s