Script that checks if there is appropriate media. We run it form cron
before the
admins & tape handlers leave for the day.
#!/usr/local/bin/perl
# Author: GJSpeier
# Date: 01/10/2001
# Modification: Please include Date and description
# 1/15/01 jas Dressed up the Report file
# Static vars:
$RECIPIENT="unix_administrators\@here.com";
$SUBJECT="Insufficient NetBackup Media";
$MAILHEADER="!!!WARNING!!!\n\nThere is insufficient media within the
following Robot(s):\n\n";
$MAILHEADER="$MAILHEADER"."\nRobot #\t Tape Pool\t\t\t Tapes needed\t Tapes
Avail.\n";
$MAILHEADER="$MAILHEADER"."-------\t -----------------\t ------------\t
------------\n";
#$MAILFOOTER="\n\nTHIS IS A TEST !!!\n";
$MAILFOOTER="\n\nThis could result in backup failures and off-hours paging
to the USG On-Call admin.\n";
# Check the libraries for available tapes. E-mail the $RECIPIENT
# If there are any problems.
@ROBOT_COUNT=("0", "1");
%ROB_0_Mon=("Arch_Off_Pool", 3, "NetBackup", 10, "NBDB_Duplicate", 2);
%ROB_0_Tue=("Arch_Off_Pool", 3, "NetBackup", 10, "NBDB_Duplicate", 2);
%ROB_0_Wed=("Arch_Off_Pool", 3, "NetBackup", 10, "NBDB_Duplicate", 2);
%ROB_0_Thu=("Arch_Off_Pool", 3, "NetBackup", 10, "NBDB_Duplicate", 2);
%ROB_0_Fri=("Arch_Off_Pool", 3, "NetBackup", 24, "Off_Site_Pool", 24,
"NBDB_Duplicate", 2, "Exchange_Pool", 3);
%ROB_1_Mon=("NetBackup", 10);
%ROB_1_Tue=("NetBackup", 10);
%ROB_1_Wed=("NetBackup", 10);
%ROB_1_Thu=("NetBackup", 10);
%ROB_1_Fri=("NetBackup", 20, "Off_Site_Pool", 20, "Exchange_Pool", 3);
# Grab today's Day
$day=`\/bin\/date \'+\%a\'`;
chomp $day;
foreach $robot_num (@ROBOT_COUNT){
$robot="ROB_"."$robot_num"."_"."$day";
foreach $media (sort keys (%$robot)){
$comm1="\/usr\/openv\/volmgr\/bin\/vmquery -h ljcqs012 -rn 0 -bx \|
awk \' \$12 \=\= \"---\" \&\& \$9 \< \\
100 \{print \$14\}\' \| sort \| uniq -c \| awk \'\{print
\$2,\$1\}\' | grep $media";
$output1=`$comm1`;
chomp $output1;
@media_detail=split(/\s+/, $output1);
if ($media_detail[1] < $$robot{$media}){
$mail="$mail"."$robot_num\t\t $media\t\t $$robot{$media}\t\t\t
$media_detail[1] \n";
}
}
}
if ($mail){
open (MESSAGE, "|/bin/mailx -s \"$SUBJECT\" $RECIPIENT");
print MESSAGE "$MAILHEADER";
print MESSAGE "$mail";
print MESSAGE "$MAILFOOTER";
close (MESSGAGE);
}
|