This is a follow-up to an earlier post regarding NetBackup where we dealt with using scripting to monitor daily NetBackup activity (actually, the time frame of the reporting was open if you wanted to change it).
In this little scriptlet, we deal with reporting on NetBackup Policies. Since this is widely variable (You name your own policies, after all), I made that part of the pattern-matching involved a variable ;). The script parses the bppllist command output using the standard -U option, which is formatted for easier reading and makes for easier line matching. Another variation on this, if you prefer to report on Types rather than Names is running bppllist with the -L option. This will give you output such as:
Policy Type: MS-Exchange-Server
and
Type: FULL SExchange
These options are addressed by including a variables section at the top of the script so that you can customize it in that way rather than deal with working your way back up through script options on top of bppllist options. In short, it's only a little less confusing, but looks a lot better. My feeling is that, in some instances it's better to have 3 slightly differently named versions of the same script that you run when you need to, rather than trying to remember 3 different ways to invoke a script that would require you to remember various patterns you needed to match.
Of course, this is presented for your assistance and, hopefully, convenience. Feel free to modify it to suit your particular needs and style.
Have a great weekend!
This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License#!/usr/bin/perl
#
# list_bp_schedules
# 2007 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#
##############################################
# Variables that should probably be edited
$names_or_types = "1"; # 0 = Types - 1 = Names
$policy_name_or_type = "MY_POLICY"; # This is treated as a regexp!
##############################################
if ( $names_or_types ) {
@bp = `/usr/openv/netbackup/bin/admincmd/bppllist -allpolicies -U`;
} else {
@bp = `/usr/openv/netbackup/bin/admincmd/bppllist -allpolicies -L`;
}
$date = `date +%m%d%y`;
open (OUTPUT, ">>Schedules.$date");
select(OUTPUT);
foreach $line (@bp) {
if ( ! $daily ) {
if ( $names_or_types ) {
print "$line\n" if ( $line =~ /Policy Name/ || $line =~ /Schedule/ );
} else {
print "$line\n" if ( $line =~ /Policy Type/ || $line =~ /Schedule/ );
}
if ( $line =~ /$policy_name_or_type/ ) {
$daily = 1;
}
} elsif ( $daily ) {
if ( $line =~ /\w/ ) {
print "$line\n";
} else {
$daily = 0;
next;
}
}
}
, Mike
linux unix internet technology