Networker

Re: [Networker] How to get a list of clients?

2008-03-31 23:24:36
Subject: Re: [Networker] How to get a list of clients?
From: Howie Jock <Jock.Howie AT NZPOST.CO DOT NZ>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Tue, 1 Apr 2008 16:20:41 +1300
You can try this on any OS

nsradmin -s BkpSrvrName -i - |sort >clients.txt
  show name
  print type: NSR client
q

and throw in uniq if you have that on your server

nsradmin -s BkpSrvrName -i - |sort |uniq >clients.txt
  show name
  print type: NSR client
q

and this one runs with Perl on Win2k with the very handy WriteExcel
module installed:

use strict; 
use Spreadsheet::WriteExcel; 
use Date::Calc qw(:all);

my($toYear, $toMonth, $toDay, $toHour, $toMin) = Today_and_Now();

my $bookname = sprintf "AllClients%02d%02d%02d%02d%02d", $toYear,
$toMonth, $toDay, $toHour, $toMin;
my $workbook  = &initExcel();
my %clients;
&getClients ("auckland01");
&writeRows($workbook, "Akld");
&getClients ("wellington01");
&writeRows($workbook, "Wgtn");

sub writeRows {
  my $workbook = shift;
  my $sheetname = shift;

  my $worksheet = $workbook->add_worksheet($sheetname);
  
  $worksheet->set_column('A:A', 14); # Column A width set to 14
  my $fmt_textwrap = $workbook->add_format();
  $fmt_textwrap->set_text_wrap();
  
  my $col = 0;
  my $row = 0;
  
  foreach my $client (sort keys(%clients)) {
    $worksheet->write($row++, $col, $client);
  }
}

sub getClients {
  my $srvr = shift;
  print "$srvr:\n";
  %clients = {};
  open (TMP, ">r.res");
  print TMP "show name\n";
  print TMP "print type:nsr client\n";
  close (TMP);
  open (Q, "nsradmin -s $srvr -i r.res 2>&1|") || die "Cannot run
nsradmin";
  
  while (<Q>) {
    chomp;
    s/^\s+//mg;            # remove leading spaces
    s/-pv1//mg;            # remove continuation lines
    s/"//mg;               # remove quotes
    # print "$_\n";
    if ( /name: (.*);/ ) {
      my $name = $1;         # eg name: alpine-pv1;
      print "$name " unless (defined ($clients{$name}));
      $clients{$name}++;
    }
  }
  print "\n";
}

sub initExcel {
  my $book = "$bookname.xls";
  print "creating $book\n";
  my $workbook = Spreadsheet::WriteExcel->new($book) or die "couldn't
create $book: $_\n";
  return $workbook;
}


-----Original Message-----
From: EMC NetWorker discussion [mailto:NETWORKER AT LISTSERV.TEMPLE DOT EDU] On
Behalf Of MIchael Leone
Sent: Tuesday, 1 April 2008 3:58 p.m.
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Subject: [Networker] How to get a list of clients?

I'd like to get a list of all my clients from NW. You might think it
would
be as simple as "mminfo -r client", but that doesn't seem to work.
Ideally,
I'd like a unique list of clients, but I'll probably have to massage the
file myself, and that's OK.

What am I missing?


--
Michael Leone
Network Administrator, ISM
Philadelphia Housing Authority
2500 Jackson St
Philadelphia, PA 19145
Tel:  215-684-4180
Cell: 215-252-0143
<mailto:michael.leone AT pha.phila DOT gov>
To sign off this list, send email to listserv AT listserv.temple DOT edu and
type "signoff networker" in the body of the email. Please write to
networker-request AT listserv.temple DOT edu if you have any problems with this
list. You can access the archives at
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER 
This email with any attachments is confidential and may be subject to legal 
privilege.  
If it is not intended for you please reply immediately, destroy it and do not 
copy, disclose or use it in any way. 

To sign off this list, send email to listserv AT listserv.temple DOT edu and 
type "signoff networker" in the body of the email. Please write to 
networker-request AT listserv.temple DOT edu if you have any problems with this 
list. You can access the archives at 
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER

<Prev in Thread] Current Thread [Next in Thread>