Perl Script
hello,
please i need your help,
how can i get a status backup with perl script, for a specific clients that are in file list (for example in the path : /usr/netbackup/myscript/clientList.txt ??
i have this script, but it's gave me the result about all clients :(
#!/usr/bin/perl
use Time::Local 'timelocal_nocheck';
$SITE = "My_Customer";
$REPORT_PATH = "/Downloads/Script-CompaNY/Reports/" ;
($datesec, $datemin, $dateh, $datej, $datem, $datea, $datesj, $dateaj, $dateisdst) = localtime (time);
$datem=$datem + 1;
$datea = $datea + 1900 ;
$_= $datem;
$count = tr/0-9// ;
if ($count eq 1) {$datem = "0$datem";}
$_= $datej;
$count = tr/0-9// ;
if ($count eq 1) {$datej = "0$datej";}
$TMSTMP= "${datea}_${datem}_${datej}" ;
$TMSTITRE= "${datej}/${datem}/${datea} ${dateh}:${datemin}:${datesec}" ;
my ($sec, $min, $heure, $jour, $mois, $annee, undef, undef, undef) = localtime(time-3600*25);
$mois += 1 and $annee -= 100;
$jour = sprintf("%02d",$jour);
$mois = sprintf("%02d",$mois);
my $BPDBJOBSDATE = "$mois/$jour/$annee $heure:$min:$sec";
$LOGFILE = "NBULog_CUSTOMER_INF_GROUP_Jour_${TMSTMP}" ;
@bpdbjobs = `/usr/openv/netbackup/bin/admincmd/bpdbjobs -gdm -t $BPDBJOBSDATE` ;
open (LOG,"> ${REPORT_PATH}${LOGFILE}") or die "Unable to open ${LOGFILE}\n";
select(LOG);
$Nbre_Jobs = 0;
$Jobs_OK = 0;
$Jobs_code_1 = 0;
$Jobs_code_58 = 0;
$Jobs_code_150 = 0;
$Jobs_Act = 0;
$Jobs_Error = 0;
$nbre_client = 0;
foreach $JOBS ( @bpdbjobs ) {
chomp ($JOBS) ;
@JOBS = split(/,/, $JOBS);
if(defined($JOBS[6]) ){
if ( $JOBS[1] eq 0) {
($sec, $min, $hour, $day, $mon, $year, $wday, $yday, $isdst) = localtime $JOBS[8];
$_= $min;
$count = tr/0-9// ;
if ($count eq 1) {$min = "0$min";}
$Mon = $mon + 1 ;
$Year = $year + 1900 ;
$STARTDATE= "${day}/${Mon}/${Year} ${hour}:${min}";
($sec, $min, $hour, $day, $mon, $year, $wday, $yday, $isdst) = localtime $JOBS[10];
$_= $min;
$count = tr/0-9// ;
if ($count eq 1) {$min = "0$min";}
$Mon = $mon + 1 ;
$Year = $year + 1900 ;
if ( $Year < 1971 ) {$ENDDATE = "N/A"; }
else {$ENDDATE= "${day}/${Mon}/${Year} ${hour}:${min}";}
if ($ENDDATE == "N/A") {@JOBS[3] = Active ;}
$Nbre_Jobs++;
if($JOBS[3] eq '0'){$Jobs_OK++; $volumeT=$volumeT+$JOBS[16]; }
elsif($JOBS[3] eq '1'){$Jobs_OK++ ;$Jobs_code_1++ ; $volumeT=$volumeT+$JOBS[16];}
elsif($JOBS[3] eq '58'){$Jobs_code_58++ ; $Jobs_Error++ }
elsif($JOBS[3] eq '150'){$Jobs_code_150++}
elsif($JOBS[3] eq 'Active'){$Jobs_Act++}
else{$Jobs_Error++}
$JOBS[6] = substr($JOBS[6], 0, 35);
$line = "$SITE;$JOBS[3];$JOBS[6];$JOBS[5];$STARTDATE;$ENDDATE;$JOBS[16];$JOBS[17];$JOBS[4]";
push(@REPORT,$line);
# }
}
}
}
$CLI_Connect = `/usr/openv/netbackup/bin/admincmd/bpplclients -allunique -l | uniq | wc -l`;
$nbre_client = `/usr/openv/netbackup/bin/admincmd/bpdbjobs -gdm -t $BPDBJOBSDATE | awk -F, '{print $7}' | sort | uniq | sed 1d | wc -l`;
$volumeT = ( $volumeT /1024 /1024);
$volumeT = substr($volumeT,0,7);
$Pourc = (($Jobs_OK / $Nbre_Jobs)*100);
$Pourc = substr($Pourc,0,5);
$Pourc_KO = (($Jobs_Error / $Nbre_Jobs)*100);
$Pourc_KO = substr($Pourc_KO,0,4);
$Pourc_Code1 = (($Jobs_code_1 / $Nbre_Jobs)*100);
$Pourc_Code1 = substr($Pourc_Code1,0,3);
print "Rapport des Jobs NetBackup pour les 25 dernieres Heures\nDate d\'execution : $TMSTITRE \n";
print "==================================================================\n";
print " Client: My_Customer Dedie\n";
print "==================================================================\n";
print "\n";
print "Detail des codes erreurs : http://www.symantec.com/docs/tech58686\n";
print "\n";
print "------------------------------------------------------------------\n";
print "\n";
printf ("%-40s%15s","Date de depart ",": $BPDBJOBSDATE");
print "\n";
printf ("%-40s%15s","Nombre TOTAL de clients connectes ",": $CLI_Connect");
printf ("%-40s%15s","Nombre TOTAL de clients sauvegardes ",": $nbre_client");
printf ("%-40s%15s","Volume TOTAL de donnees sauvegardees",": $volumeT Go");
print "\n";
print "------------------------------------------------------------------\n";
print "\n";
print "Nombre TOTAL de Jobs : $Nbre_Jobs\n";
print "Nombre de Jobs OK : $Jobs_OK\n";
print "Nombre de Jobs Incomplets (code 1) : $Jobs_code_1\n";
print "Nombre de Jobs Code 58 (cannot connect) : $Jobs_code_58\n";
print "Nombre de Jobs termine par admin : $Jobs_code_150\n";
print "\n";
print "------------------------------------------------------------------\n";
print "\n";
print "Nombre de Jobs Actifs : $Jobs_Act\n";
print "\n";
print "------------------------------------------------------------------\n";
print "\n";
print "Nombre de Jobs en ERREUR : $Jobs_Error\n\n";
print "------------------------------------------------------------------\n";
print "\n";
print "Pourcentage de reussite : $Pourc %\n";
print "Pourcentage en erreur : $Pourc_KO %\n";
print "Pourcentage Code 1 : $Pourc_Code1 %\n";
print "\n";
print "-" x 135;
print "\n";
print "-" x 135;
print "\n";
printf("%-17s%-7s%-35s%-13s%-16s%-16s%-12s%-10s%-20s%-20s\n","Site","Status","Client","Type","Start","End","KBytes","Files","Policy");
print "-" x 135;
print"\n";
foreach $LINE ( @REPORT ) {
@DATA = split(/;/,$LINE);
printf("%-17s%-7s%-35s%-13s%-16s%-16s%-12s%-10s%-20s%-20s\n",$DATA[0],$DATA[1],$DATA[2],$DATA[3],$DATA[4],$DATA[5],$DATA[6],$DATA[7],$DATA[8]);
}
close(LOG) ;
thanks in advance !
hello Miackael,
yes right, is that exactly what i need, but i don't know how to do it :(