NetBackup statistics, Part II
This script uses the output of the script in the previous example to calculate yearly backup load for each Veritas NetBackup client.
#!/bin/ksh WORKDIR=/var/adm/bin/bpstat BACKUPS=$WORKDIR/backups STATDIR=$WORKDIR/stats PROCESS=1 gzip="/usr/local/bin/gzip" if [ ! -d $WORKDIR ] || [ ! -d $BACKUPS ] || [ ! -d $STATDIR ] || [ `find $BACKUPS -type d | wc -l` -eq 0 ] then echo "Souce directories not found. Exiting..." exit fi if [ $PROCESS -eq 1 ] then if [ `find $STATDIR -type f | wc -l` -gt 0 ] then rm $STATDIR/* fi month="01" day="01" year="01" for year in 03 04 05 06 07 08 09 10 do for month in 01 02 03 04 05 06 07 08 09 10 11 12 do for day in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 do if [ -d $BACKUPS/$month$day$year ] then echo "Processing $BACKUPS/$month$day$year" if [ -f $BACKUPS/$month$day$year/final_output_cron.txt.gz ] then $gzip -d $BACKUPS/$month$day$year/final_output_cron.txt.gz cat $BACKUPS/$month$day$year/final_output_cron.txt | grep -v ZZTOTAL | while read line do HOST=$(echo "$line" | awk -F',' '{print $1}') SIZE=$(echo "$line" | awk -F',' '{print $2}') if [ $HOST ] && [ $SIZE ] then echo "$HOST,$month-$day-$year,$SIZE" >> "$STATDIR/$HOST" fi done $gzip $BACKUPS/$month$day$year/final_output_cron.txt fi fi done done done fi if [ -f $WORKDIR/combined_yearly_stats.csv ] then rm $WORKDIR/combined_yearly_stats.csv fi find $STATDIR -type f | while read file do cat $file >> $WORKDIR/combined_yearly_stats.csv done if [ -f $WORKDIR/combined_yearly_stats.csv ] then chmod 777 $WORKDIR/combined_yearly_stats.csv fi chmod -R 777 $STATDIR ftp -in webserver << bye user username password lcd /var/adm/bin/bpstat cd /var/apache/htdocs/bpstat put combined_yearly_stats.csv lcd /var/adm/bin/bpstat/stats cd /var/apache/htdocs/bpstat/stats mput * bye (( MINUTES = SECONDS / 60 )) echo "Processing and transfers complete in $MINUTES minutes"
Popularity: 2% [?]
Related posts:


