Informing the IBM Community

Masterclass: advanced vSCSI disk monitoring (includes scripts)

0
(0)

Operator

In my previous article, I showed how you can use nmon in VIOS to display the performance statistics of hdisks that are mapped to client LPARs. This is achieved by creating a file which nmon reads and then displays the relevant performance data. The script I used required that the virtual target devices (VTDs) mapped to your LPARs use the naming convention LPARNAME_Lxx.

In this article, I’ll provide you with the details for two scripts:

1.    Display disk stats per LPAR using the LPAR ID.
2.    Display disk stats per disk for a specific LPAR.

Display disk stats using the LPAR ID

This will produce the same results as the lsnmondisks.ksh script but will work regardless of the naming convention used for your VTDs.

In this script, I get a list of all the LPARs which are active on the system by using the LPARID field using the command:

lsmap -all -field clientid backing -fmt , |grep -v 0x00000000|grep hdisk >$LSMAP

The -field parameter of the lsmap command allows me to specify which fields I want displayed rather than trawling through all the lsmap data. I select just the LPARID and BACKING fields. The BACKING field is the name of the physical device we map to the LPAR. So this command will provide me with a comma-separated list of LPARIDs with their assigned hdisks.

The rest of the script sorts the list into a unique, sorted list of LPARIDs and then extracts the hdisks associated with the LPARID so that we only have a single line per LPAR.

As before, make sure you’re running in an AIX shell by running:

oem_setup_env (or aix if you have that set up as an alias)

When I run ./lslpariddisk.ksh, I get the following:

1 - lslpariddisks output

As you can see, the script refers to the LPAR ID rather than the LPAR name. I’ve asked around IBM to see if there’s a way to retrieve the LPAR name but it appears there isn’t unless I get my script to call a command on the HMC. That would make the script too complicated for most people so I’m sticking with the LPAR ID.

If anyone knows how I can achieve this in VIOS please let me know. The annoying part is that if I get NPIV information rather than vSCSI information, the lsmap command will return the LPAR name.

So, the data collection is complete and I need to see the results in nmon. Run the command:

nmon -g /tmp/lpar.hdisksgrp

At the nmon main menu, press g and you should get something similar to the following:

2 - nmon results

As you can see, I’ve had to auto-generate the name field based upon the LPARID because the lsmap command doesn’t provide me with the LPAR name. You can get the LPAR name from the HMC.

As with my previous script, this shows you disk stats per LPAR. What I also want is to break down the stats per disk for a specific LPAR.

Display disk stats per disk for a specific LPAR

This script requires you to provide the names of the vSCSI vhost adapters associated with your LPAR. It will then extract all the hdisks associated with the LPAR and provide stats in nmon on a per disk basis.

For example, if my client LPAR has vhost9, vhost10 and vhost11 assigned to it, I would run:

./lslpardisk.ksh vhost9 vhost10 vhost11

This would show:

3 - lslpardisks output

So you can see that the script has identified the individual hdisks for the vhosts you specified.

When I run nmon -g /tmp/lpar.hdisks, I can see:

4 - nmon results per disk

Now I can see an entry for each disk mapped to my LPAR and the associated disk statistics. Using my naming convention of LPARNAME_Lxx should make identifying the disks on the SAN, in VIOS and on the client LPAR easier.

The scripts in the previous article and this article should allow you to monitor and interrogate disk performance.

What next?

These articles have covered vSCI attachment of volumes from an external storage device. I have recently been using a system with version 4 of Shared Storage Pools. I have created a couple of scripts to ease the pain of creating a large number of volumes. In my next article, I will cover SSPs and the scripts I used to create and map the volumes from the SSP.

Glenn Robinson has been PowerWire‘s resident tech tipster for over a decade. He has worked in the IBM computing arena since 1986 on System/34/36/38 and AS/400 through to Power Systems today.

As systems architect for IBM systems and storage at RSI Consulting, based in Northampton, UK, he works predominantly with IBM i clients as well as those using AIX and Linux. In the last five years, he has also had a great deal if experience working with Power customers using SVC and V7000 storage virtualisation.

lslpariddisk.ksh
#!/bin/ksh
#
# Author:     Glenn Robinson
# Script:       lslpariddisks.ksh
# Create a list of hdisks per LPAR to use with nmon -g function
# Note that only Active LPARs are processed by this script
#
# Usage:     ./lslpariddisks.ksh
#
 
set +x
exec 2>/dev/null
 
FILE=/tmp/lpar.hdisksgrp
TMPFILE=/tmp/lpars.out
LSMAP=/tmp/lsmap.out
HDISK=""
i=/usr/ios/cli/ioscli
 
clear
# Remove any existing files
rm $FILE $TMPFILE $VTDS >/dev/null
 
# Create a list of the LPARs
# Filter out virtual cd and dvd devices
print "Generating mapping list for all LPARs, please be patient..."
 
# List the LPARs and their mapped hdisks
# Ignore clientid of zero as these are inactive LPARs
$i lsmap -all -field clientid backing -fmt , |grep -v 0x00000000|grep hdisk >$LSMAP
 
# Get a unique, sorted list of active LPAR IDs
cut -f 1 -d , $LSMAP|sort|uniq | while read LPARID
 
do
        LPARDEC=$(printf "%d" $LPARID)
        print "Retrieving hdisks for LPAR: "$LPARDEC
        HDISKS=""
        # Get all lines for the LPARID and retrieve the hdisk entries only
        for HDISK in $(grep $LPARID $LSMAP| awk -F, '{ print substr($0, index($0,$2)) }'| tr "," " " )
        do
                if [[ $HDISK == hdisk* ]]; then
                       HDISKS=$HDISKS","$HDISK
                fi
        done
 
# Write the list of hdisks for the LPAR to the file to be used by nmon
echo "LPARID$LPARDEC $HDISKS">>$FILE
done
 
rm $TMPFILE $VTDS >/dev/null
 
echo "\n\nFile: "$FILE" is now populated with LPAR hdisk information\n\n"
echo "Execute: nmon -g "$FILE
echo "At the nmon display press g to display the disk stats per LPAR" 

lslpardisk.ksh

#!/bin/ksh
# Program: lslaprdisk.ksh
# Author:  Glenn Robinson
#
# Description: List the hdisks and backing devices (VTDs) for one or more vhosts and place in to
# a file which can be used by nmon -g
#
# Usage: lslpardisk.ksh vhostA vhostB vhostC
#
# e.g. lslparhdisk.ksh vhost14 vhost15 vhost28 - will print the VTDs and associated hdisks for the three
# vhosts passed to this script
#
 
set +x
exec 2>&1
I=/usr/ios/cli/ioscli
FILE1=/tmp/file1
FILE2=/tmp/file2
FILE3=/tmp/lpar.hdisks
VHOST=$1
 
# Housekeeping
rm $FILE1 $FILE2
 
clear
echo "Processing vhosts . . . \n"
 
# Loop around processing all vhosts specified on the command line
while [[ ${#} -gt 0 ]];
do
 
        # Generate list of backing devices (VTDs) - only select those with an hdisk device
        $I lsmap -vadapter $VHOST -field vtd backing|grep -p hdisk|grep -i " "|awk '{ print $NF }'|grep -v hdisk >>$FILE1
        # Generate list of hdisks
        $I lsmap -vadapter $VHOST -field vtd backing|grep -p hdisk|grep -i " "|awk '{ print $NF }'|grep  hdisk >>$FILE2
        shift
        VHOST=$1
done
paste $FILE1 $FILE2 >$FILE3
 
# Display on screen
echo "VTDs and associated hdisks for your vhost selection: \n"
cat $FILE3
echo "\nTo use this file with nmon type:"
echo "nmon -g "$FILE3
echo "At the nmon menu press g to display the LPAR disks\n\n"

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.