rendered paste body#!/usr/bin/perl
###########
#
#
#
#
#
#####
######
# Do not remove or disable without good documented reason.
#
use strict;
use warnings;
# addtional
use Getopt::Std;
#
######
######
# Variable processing
#
# Make our variables global
# any new config variable belongs here
#
use vars qw($NSRSERVER $NSRADM $NSRJB $RTMP $DEBUG %options
@CLUSTERNODES $SNMPCOM $NSRTRAP $TMPCMDFILE $NSRMM);
#
######
#####
# set the defaults here and copy block to
# "/usr/ngscore/config/'progname'.conf" file
#
## ## start config block ##
#
#
#
# the Name of the clustered
# NetWorker server
$NSRSERVER="sdp_nsr";
#
# the names of the cluster nodes primary node first
@CLUSTERNODES=("sdp1","sdp2");
#
#
$SNMPCOM="public";
#
# trap program
$NSRTRAP="/usr/bin/nsrtrap";
#
# setup the temp dir we'll use
$RTMP="/nsr/tmp";
#
$TMPCMDFILE="$RTMP/nsradmin-in";
#
##### end variable default
#
# initialize some variables
$DEBUG=0;
#####
# set up our options
#
# -D: debug
# -u: update only
# -r: create only
# -c: config file
#
#
getopts('Durc:',\%options);
#
#
##### read in config files
if ($options{c}) {
if ( -e "$options{c}") {
print "reading $options{c}\n";
no strict 'refs';
open ( CONF, "$options{c}") || die "cannot open config: $!\n";
my $conf = join "", <CONF>;
close CONF;
eval $conf;
die "Couldn't eval config file: $@\n" if $@;
print "config file loaded\n";
} else {print "Config file not found, using defaults\n";}
}
#####
#
# Set up the program locations we'll use
#
# nsradmin location
$NSRJB="nsradmin";
#
# nsradmin
$NSRADM="nsradmin";
#
# nsrmm location
$NSRMM="nsrmm";
#
####
####
# set up command line switches
#
# just makes code easier to read
$DEBUG=1 if $options{'D'};
#
#####
print "Debug set\n" if $DEBUG;
#
#
#####
#
sub update_stock_config {
my @cl_admprivs;
my $cl_admprivs_print;
my $createadm="";
foreach my $cn (@CLUSTERNODES) { # Nota: cn = clusternode
chomp($cn);
print "configure $cn ...\n" if $DEBUG;
$createadm="host="."$cn";
print "$cl_admprivs_print ...\n" if $DEBUG;
push(@cl_admprivs, $createadm);
}
$cl_admprivs_print = join (@cl_admprivs, ',');
print "cluster hosts admin config\n: $cl_admprivs_print\n" if $DEBUG;
# Create tempfile containing nsradmin commands
#open (NSRCMD, "> $TMPCMDFILE");
print << "UPDATE";
action: "$NSRTRAP -c $SNMPCOM -t 6 $NSRSERVER";
name: Resource File Corruption;
type: NSR notification;
y
action: "$NSRTRAP -c $SNMPCOM -t 6 $NSRSERVER";
name: Bootstrap Backup Failure;
type: NSR notification;
y
action: $NSRTRAP -c $SNMPCOM -t 6 $NSRSERVER;
name: Bootstrap;
type: NSR notification;
y
action: "$NSRTRAP -c $SNMPCOM -t 6 $NSRSERVER;
event: Savegroup;
name: Savegroup completion;
type: NSR notification;
y
action: "$NSRTRAP -c $SNMPCOM -t 6 $NSRSERVER";
name: NetWorker Daemons Not Running;
type: NSR notification;
y
name: Administrators;
type: NSR usergroup;
users: "host=$NSRSERVER, $cl_admprivs_print";
y
UPDATE
# print NSRCMD "quit\n";
# close (NSRCMD);
# call nsrdadmin and use the tempfile
#
#print "$nsradmsrv\n";
#print "running nsradmin\n";
#open (NSRADM, "nsradmin $nsradmsrv -i $TMPCMDFILE 2>&1|") || die "Cannot start nsradmin: $!\n";
#my @hostid_in=<NSRADM>;
close (NSRADM);
# remove the temp command file
#
#unlink ($TMPCMDFILE);
}
update_stock_config();