Networker

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

2005-07-12 14:04:27
Subject: Re: [Networker] identifying storage nodes and their clients.
From: Darren Dunham <ddunham AT TAOS DOT COM>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Tue, 12 Jul 2005 11:00:11 -0700
> That is a good start but that's where I kinda already was.  I'm trying to
> get the data in reverse so there'd be a listing kinda like this:
> sn1
>    client1
>    client2
>    client3
> sn2
>    client4
>    client5

Well, you were asking about the nsradmin part.  If you've got that,
you're done there.  It can't give you information it doesn't have.  The
rest is up to you.  In this case, I don't believe it maintains any index
from storagenode to client.

For me, this is perfect for a perl hash.  Read in all the clients, push
to a hash, then print out.  As an example, say you have the following
data:

alpha           sn1
bravo           sn2
charlie         sn1
delta           sn1
echo            sn2
foxtrot         bigserve
golf            sn2
hotel           bigserve

Not the same format as nsradmin, but that's a minor point.  You can feed
that into something like this...

#!/bin/perl -n

my ($client, $storagenode) = split;  # assuming no spaces in data
push @{$sn{$storagenode}}, $client;

END {
    foreach my $storagenode (sort keys %sn) {
        print "$storagenode\n";
        foreach my $client (sort @{$sn{$storagenode}}) {
            print "     $client\n";
        }
    }
}


% /tmp/perl /tmp/data
bigserve
     foxtrot
     hotel
sn1
     alpha
     charlie
     delta
sn2
     bravo
     echo
     golf

That's just a perl example.  You could use awk or something else you
feel more comfortable with.


-- 
Darren Dunham                                           ddunham AT taos DOT com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

--
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
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=