Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to list servers by storage node?

Status
Not open for further replies.

hermxl1

IS-IT--Management
Feb 12, 2004
24
US
Hi,

I'm in a very large environment with about 6 Legato servers each with 2 to 3 storage nodes and about 700 clients per server.

My problem is that for a given server, want to generate a list of clients per storage node. I've tried using the nsradmin command but I would like all the info for each client on 1 line. Is there any way to do this?

Thanks

Herman
 
Certainly, use nsradmin and supply it with print type: NSR client

Put the output into a file, then, on Unix, use awk or , on Windows, use vb/vbscript to parse the file and print storage node, client lines.
Sort the output of this and you have what you want.
 
TDun,

I guess I need to investigate awk scripting capabilities more. I thought all the output for each client had to be one line for awk to help.

Thannks,

 
No, you can getline (at least you can with nawk (new awk)).
 
There are lots of ways to do this. Obviously nsradmin is the key, but you can package this up in various languages to format the output, perl, awk, shell etc. For a fairly trivial query like this I would just knock up a short shell script. I can think of two different approaches to this:

(1) List all clients and their storage nodes field. Complication with this is that the storage nodes field can hold multiple values, such as:
"nodeA"
"nodeA, nodeB"
so sorting them might not group the clients together as you might wish.

(2) Specify a storage node and query all clients using it. This way, a query for "nodeA" will match both examples above, but a query for "nodeB" will only match the latter. nsradmin is quite clever sometimes.

Let's use (1) for an example script below.
Code:
#!/bin/ksh
# showclientsbynode
SERVER=${1:-$(uname -n)}
echo "
        show name; storage nodes
        print type: NSR client
        " | nsradmin -s $SERVER -i - | sed 's/;//' | while read LINE; do
        ATT=$(echo $LINE | cut -d: -f1 | sed 's/^ //')
        VAL=$(echo $LINE | cut -d: -f2 | sed 's/^ //')
        if [ "$ATT" = "name" ]; then
                NAME=$VAL
        elif [ "$ATT" = "storage nodes" ]; then
                SNODE=$(echo $VAL | sed 's/,/ /g')
                echo "$SNODE,$NAME"
        fi
done | sort -u
Output is CSV format suitable for reading in to most spreadsheet packages.

Or if we want to do (2) it could look like this:
Code:
#!/bin/ksh
# queryclientsbynode
SNODE=$1
if [ -z "$1" ]; then
        echo "Specify storage node"
        exit 1
fi

SERVER=${2:-$(uname -n)}
echo "
        show name
        print   type            : NSR client;
                storage nodes   : $SNODE
        " | nsradmin -s $SERVER -i - | sed 's/;//' | while read LINE; do
        ATT=$(echo $LINE | cut -d: -f1 | sed 's/^ //')
        VAL=$(echo $LINE | cut -d: -f2 | sed 's/^ //')
        [ "$ATT" = "name" ] && echo $VAL
done | sort -u
Neither of the scripts have much in the way of bells and whistles (error checking, comments etc.) as I just knocked them up in 5 minutes, but it should give you the general idea of how it can be done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top