Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help writing a script

Status
Not open for further replies.

chekcol

MIS
Apr 9, 2003
55
US
Hey guys.....

Need help writing a script that will do the following...any help would be greatly appreciated.

I am writing an automation script and it needs NetWorker functions in that script that can do the following:


1. Set target sessions on every device to some number I specify
2. Set max sessions (new in 7.3) on every device to some number I specify
3. Stop networker (must finish)
nsr_shutdown -f (this will force nsr_shutdown to terminate all Networker services if a graceful shutdown fails)
4. Start networker
5. Verify networker storage node is ready for action
6. Break a storage node so that nw will fail when it tries to back it up
7. Fix that same client
8. Tell a particular storage node to back up to its own devices
9. Tell a particular storage node to back up to another storage node's devices
10. Set client parallelism to a value that I specify
11. Run a single group and wait until it finishes before moving on
12. Run a bunch of groups at once, then wait until they ALL finish before moving
 
Hi,

So is it shell script or PERL or something else we are looking at? What part of the script is it you need help with?
 
nothing as of yet....cannot write a script at all....
 
Well, we can't really write a complete script for you, that would take too long. I would however suggest that the script be written in perl as this is the best script language as far as i see it. You need to know how to user nsradmin as well as mminfo in order to write this script. Below is a short example of how to set target sessions and max target sessions using nsradmin and a bit of (ugly) perl code. Copy paste it into a text document and name it to what ever you want but give it the extension ".pl" (device.pl for example). Run it with "device.pl -t number" or "device.pl -mt number" for setting Target or Max Target sessions to whatever "number" you specify. I suggest you try it on a test server at first... Hope this helped pointing you in the right direction
and please know that the below code is just a small "quick and dirty" example.

-----------------------------------
#!/usr/bin/perl

use strict;
my @array;

# Update Target Sessions
if($ARGV[0] eq "-t" && $ARGV[1] ne undef) {
print "\nSetting Target Sessions on all devices to '$ARGV[1]'\n";

# Set new target sessions
open (FILE, ">cdevice.tmp");
print FILE ". NSR device\nupdate target sessions: $ARGV[1]\n";
close (FILE);

`nsradmin -i cdevice.tmp`;

# Print new config
open (FILE, ">device.tmp");
print FILE ". NSR device\ntarget sessions\np\n";
close (FILE);

@array = `nsradmin -i device.tmp |grep "target sessions" |uniq`;
foreach(@array) {
s/^\s+//;
print $_;
}
}

# Update Max Target Sessions
if($ARGV[0] eq "-mt" && $ARGV[1] ne undef) {
print "\nSetting Max Target Sessions on all devices to '$ARGV[1]'\n";

# Set new target sessions
open (FILE, ">cdevice.tmp");
print FILE ". NSR device\nupdate max sessions: $ARGV[1]\n";
close (FILE);

`nsradmin -i cdevice.tmp`;

# Print new config
open (FILE, ">device.tmp");
print FILE ". NSR device\nmax sessions\np\n";
close (FILE);

@array = `nsradmin -i device.tmp |grep "max sessions" |uniq`;
foreach(@array) {
s/^\s+//;
print $_;
}
}

unlink('device.tmp');
unlink('cdevice.tmp');
------------------------------------------

Cheers!
Maverick
 
Thanks for the help and example....just wasn't sure on how to setup in the script.....i figured nsradmin but not sure how I would layout.

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top