Prasad Koyi

001-347-349-KOYI (5694)

script to find policy details

on November 20, 2012

#!/usr/bin/ksh
#
#
#script gets a list of hosts as its input file and then reports on policies,
#schedules and datasets pertaining to each host (prasad@svtechinc.com)
#
#
#
#
#

AWK=/bin/awk
NAWK=/bin/nawk
GREP=/bin/grep
SED=/bin/sed

BPPLCLIENTS=/usr/openv/netbackup/bin/admincmd/bpplclients
BPPLLIST=/usr/openv/netbackup/bin/admincmd/bppllist
BPPLINFO=/usr/openv/netbackup/bin/admincmd/bpplinfo
BPPLINCLUDE=/usr/openv/netbackup/bin/admincmd/bpplinclude
BPPLSCHED=/usr/openv/netbackup/bin/admincmd/bpplsched
BPRETLEVEL=/usr/openv/netbackup/bin/admincmd/bpretlevel

function usage {
print “USAGE: `basename $0` infile”
exit 1
}

function get_info_on_host {

Sol=”Solaris File Backup”
Win=”Windows File Backup”
Ora=”Oracle Instance”
MSSQL=”MS SQL Instance”
SAP=”SAP Backup”
Lotus=”Lotus Domino Backup”

if (( $# /dev/null 2>&1
then
for ClassName in `$BPPLLIST -byclient $Host | $GREP -i class | $AWK ‘{print $2}’`
do
ClassType=`$BPPLINFO $ClassName -U | $NAWK ‘
$1 ~ /Policy/ && $2 ~ /Type/ && $3 ~ /Standard/ {print sol}
$1 ~ /Policy/ && $2 ~ /Type/ && $3 ~ /MS-Windows-NT/ {print win}
$1 ~ /Policy/ && $2 ~ /Type/ && $3 ~ /Oracle/ {print ora}
$1 ~ /Policy/ && $2 ~ /Type/ && $3 ~ /MS-SQL/ {print sql}
$1 ~ /Policy/ && $2 ~ /Type/ && $3 ~ /SAP/ {print sap}
$1 ~ /Policy/ && $2 ~ /Type/ && $3 ~ /Lotus/ {print lotus} ‘ “sol=$Sol” “win=$Win” “ora=$Ora” “sql=$MSSQL” “sap=$SAP” “lotus=$Lotus” `

IsActive=`$BPPLINFO $ClassName -U | $AWK ‘
$1 ~ /Active/ && $2 ~ /yes/ {print “Active”}
$1 ~ /Active/ && $2 ~ /no/ {print “Disabled”} ‘`

DataSet=””

if [[ $ClassType == $Sol || $ClassType == $Win || $ClassType == $Lotus ]]
then
DataSet=`$BPPLINCLUDE $ClassName -U | $GREP -v NEW_STREAM | $NAWK ‘
$2 ~ “Shadow” { print “System_State:\\\”}
$2 !~ “Shadow” { print $2 } ‘ | $SED ‘s/\\\\/\\\\\\\\/g’ `
fi

if [[ $ClassType == $Ora ]]
then
DataSet=”Oracle DB”
fi

if [[ $ClassType == $SAP ]]
then
DataSet=”SAP”
fi

for SchedName in `$BPPLSCHED $ClassName -U | $AWK ‘$1 ~ /Schedule/ && $2 !~ /Default/ {print $2}’`
do
SchedType=`$BPPLSCHED $ClassName -U -label $SchedName | $AWK ‘ BEGIN {
Full=”Full”
DInc=”Differential Incremental”
CInc=”Cumulative Incremental”
UBak=”User Backup”
UArc=”User Archive”
}

$1 ~ /Type/ && ($2 ~ /Full/ || $3 ~ /Full/) {print Full}
$1 ~ /Type/ && ($2 ~ /Diff/ || $3 ~ /Diff/) {print DInc}
$1 ~ /Type/ && ($2 ~ /Cumu/ || $3 ~ /Cumu/) {print CInc}
$1 ~ /Type/ && $2 ~ /User Backup/ {print UBak}
$1 ~ /Type/ && $2 ~ /User Archive/ {print UArc} ‘`

RetLevel=`$BPPLSCHED $ClassName -U -label $SchedName | $AWK ‘ $1 ~ /Retention/ && $2 ~ /Level/ {print $3}’ `
RetLevelDescr=`$BPRETLEVEL -U | $AWK ‘{ if ( $1 == rl ) print $3, $4 }’ “rl=$RetLevel” `

Freq=`$BPPLSCHED $ClassName -U -label $SchedName | $AWK ‘ $1 ~ /Frequency/ {print $2, $3, $4} ‘`
Window=`bpplsched $ClassName -U -label $SchedName|egrep -i “Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday” |grep “:00″`
if [[ $ClassType == $Sol || $ClassType == $Win || $ClassType == $Lotus ]]
then
for entry in `print $DataSet`
do
print -r “$Host, $entry, $ClassName, $IsActive, $SchedName, $SchedType, $Freq, $RetLevelDescr,$Window”
done
fi

if [[ $ClassType == $Ora || $ClassType == $SAP ]]
then
print “$Host, $DataSet, $ClassName, $IsActive, $SchedName, $SchedType, $Freq, $RetLevelDescr,$Window”
fi

if [[ $ClassType == $MSSQL ]]
then
print “$Host, $MSSQL, $ClassName, $IsActive, $SchedName, $SchedType, $Freq, $RetLevelDescr,$Window”
fi

done
done
fi

}

if (( $# < 1 ))
then
usage
fi

InFile=$1

if ! [[ -r $InFile ]]
then
print "`basename $0`: can't read input file $InFile"
exit 1
fi

for host in `cat $InFile | $NAWK '{ print tolower($1) }'`
do
get_info_on_host $host
done


Leave a comment