Networker

Re: [Networker] identifying storage nodes and their clients.

2005-07-18 18:06:05
Subject: Re: [Networker] identifying storage nodes and their clients.
From: "Brian J. Greenberg" <bgreenberg AT GLASSHOUSE DOT COM>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Mon, 18 Jul 2005 18:00:10 -0400
This script is so close.  I have a many to many relationship for storage
nodes and clients.  For example, the output of the nsradmin script:

echo "
        show name; storage nodes
        print type: NSR client
        " | nsradmin -s $SERVER -i -

is:

         name: client1
storage nodes: client1

         name: client4
storage nodes: client4, client6, client7, nsrserverhost

         name: client2
storage nodes: client5, client3

         name: client8
storage nodes: client9, client3, nsrserverhost

         name: client10
storage nodes: client6, nsrserverhost

So, what I'm going for then is something that would do a parent ->
children relationship.  Where the desired final output from a script of
the prior nsradmin output would be something like:

StorageNode    Clients
============   =============================
client1        client1
client4        client4
client6        client4, client10
client7        client4
client5        client2
client3        client2, client8
client9        client8
nsrserverhost  client4, client8, client10

Haven't quite figured out how to write that.  Any suggestions?

Brian

On Wed, 13 Jul 2005 14:02:56 +0100, Davina Treiber <Treiber AT HOTPOP DOT COM>
wrote:

>Brian Greenberg wrote:
>> Does anyone have a shell script that would generate a report of all the
storage nodes on an nsr server and all the clients for that storagenode
that I could easily import into excel?
>>
>> I'm trying to generate a report that would give me something like this:
>>
>> NSR Server   StorageNode    Client(s)
>> server1      sn1            client1   client2   client3   client4
>>              sn2            client5   client6   client7   client8
>>
>
>
>Here's a pretty simple no frills script to do this. It's flawed slightly
>because the client-storage node relationship is many to many, and this
>scripts works on the assumption that you will only have one storage node
>defined for each client. It could be improved a lot, but since you
>really only wanted to see how the nsradmin commands work it should be
>sufficient.
>
>#!/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

--
Note: To sign off this list, send a "signoff networker" command via email
to listserv AT listserv.temple DOT edu or visit the list's Web site at
http://listserv.temple.edu/archives/networker.html where you can
also view and post messages to the list. Questions regarding this list
should be sent to stan AT temple DOT edu
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=