Networker

Re: [Networker] mminfo not equal query

2004-04-07 19:17:52
Subject: Re: [Networker] mminfo not equal query
From: Darren Dunham <ddunham AT TAOS DOT COM>
To: NETWORKER AT LISTMAIL.TEMPLE DOT EDU
Date: Wed, 7 Apr 2004 16:17:49 -0700
> It does, thanks. I have used the newline method before, although I
> normally only split it with a newline after each field that might
> contain spaces. Perhaps it's simpler your way. I'll examine your code,
> that will be useful. Although I've written some reasonably complex Perl
> programs myself, Perl is so powerful that I consider myself to be still
> learning. I still think in ksh, even though I can see the benefits of
> Perl.

If there were only a few pools in the system, I would probably run one
query to list them all, then run multiple 'mminfo' for each of the
pools.  Slightly longer, but very safe.

If there were so many pools that I didn't want to do that, I'd probably
do something similar to your first suggestion.

Put pool at the beginning with a sufficiently large field size and take
it off with substr.  Then split on whitespace for everything after that.
You could put pool anywhere in the line if mminfo would always give you
the space you asked for in a field... (it doesn't).  Putting it first
avoids that issue.

my @fields = qw/pool(20) volume client ssid nsavetime name/;
my $report = join(",", @fields);
my @mminfo_output = `mminfo -av -r '$report'`;
shift @mminfo_output;  # pop off the header line.
chomp @mminfo_output;

my $split_fields = @fields - 1;  # leave any things in 'name' in the last field
foreach my $line (@mminfo_output) {
  my $pool = substr($line, 0, 19, "");
  # if the trailing whitespace is a problem, trim it here..
  $pool =~ s/\s+$//;

  my @line_info = split (' ', $line, $split_fields);
  unshift (@line_info, $pool);

  # now all the fields are in @line_info in @fields order.
  # you could put them in a hash.
  my %hash;
  my $index;
  foreach my $record (@fields) {
    $record =~ s/\(.*$//;
    $hash{$record} = $line_info[$index];
    $index++;
  }

  print "Pool => *$hash{$pool}*, Name => *$hash{$name}*\n";
}





--
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 listmail.temple DOT edu or visit the list's Web site at
http://listmail.temple.edu/archives/networker.html where you can
also view and post messages to the list.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

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