Networker

Re: [Networker] Question about nsradmin scripting

2005-02-02 13:40:27
Subject: Re: [Networker] Question about nsradmin scripting
From: Darren Dunham <ddunham AT TAOS DOT COM>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Wed, 2 Feb 2005 10:33:22 -0800
> 
> I am trying to write a perl script under Solaris 9 with a NetWorker 7.1.2
> server running on it.  I am not clear on how to script what should be a
> simple nsradmin query.

I'm not sure what you're asking here.  Are you asking how to make the
query with perl, or how to formulate the query (I don't know that it's a
simple query)?

> What I want is a list of clients names that are members of a scheduled
> group, plus the name of the group, and the backup schedule setting on the
> group. I want to exclude groups that are not scheduled and clients that
> are not assigned to any group.  I want to output this list to a file so I
> can link it with mminfo and also generate a report in html format that
> lists each client, group name, and when its backup is scheduled. In case
> it makes any difference, we use the group entry to schedule backups, not
> the client entry.
> 
> If anyone already has perl code that does this, please let me see it.

I don't have perl code that does that, but I've posted some code in the
past that does similar things.  Looks like one of the first things you
want is to get a list of groups that are scheduled (enabled).

The query for that might be...
nsradmin> show name;
nsradmin> print type:nsr group; autostart:enabled

And here's an example of how to code that (in 5.003 compatible
code.. this is a bit easier in 5.6+.  Also, there's no error
checking... *PLEASE* add error checking in your own code).

#!/usr/bin/perl -w
use strict;

use IPC::Open2;
my $pid = open2(\*RDRFH, \*WTRFH, "nsradmin -i -");

# send some commands to nsradmin.
print WTRFH "show name\n";
print WTRFH "print type:NSR group; autostart:enabled\n";
close WTRFH;

# get the results.
my @output = <RDRFH>;

print @output;


You'd have to parse @output a bit to pull the names out exactly.  But
once done, you can then use that to form other queries.

For each group, find all clients that are members of that group:
  show name
  print type:nsr client; group:$group


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

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