#!/usr/bin/perl # # Program: netbackup-tape-speed.pl # Description: Summarise NetBackup tape drive speed # Version: 1.5 # Last Update: 12 February 2004 # Written by: Dusan U. Baljevic # # Copyright 2004-2014 Dusan Baljevic # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Make the script very tight. # $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/sbin:/usr/openv/netbackup/bin:/usr/openv/netbackup/bin/admincmd'; $ENV{'SHELL'} = '/bin/sh' if $ENV{'SHELL'} ne ''; $ENV{'IFS'} = '' if $ENV{'IFS'} ne ''; use Getopt::Std; use POSIX 'uname'; (undef, $Hostname, undef, undef, undef) = uname; ($::opt_t) = (); #avoid warning message getopts('t:'); $::SAFile = $::opt_t; if (! "$SAFile" ) { $FF = "24"; } else { $FF = "$SAFile"; } print "\nINFO: Processing NetBackup logs for last $FF hours...\n\n"; # List Netbackup Master and Media servers: # open(XYZ,"bpgetconfig |") || die "Cannot run bpgetconfig report\n"; print "NetBackup Master/Media server:\n"; while () { print " $_" if grep(/^SERVER |^SERVER=/, $_); } # List Netbackup Master and Media servers: # open(VVV,"< /usr/openv/netbackup/version") || die "Cannot list NetBackup version report\n"; print "NetBackup Version:\n"; while () { print " $_"; } close XYZ; close VVV; print "\n ImageID MediaID Fragment DriveIdx Written Speed_Written\n"; print "----------------------------------------------------------------------------------------------------\n\n"; open(FROM,"bperror -hoursago $FF | awk '/begin|wrote/ && ! /awk/ {print}'|") || die "Cannot open bperror data"; while () { chomp; if (grep(/begin/, $_)) { undef $Line; undef $ImageID; undef @Image; undef @Frag; undef $DriveIndex; undef $Fragment; undef $MediaID; @Keyspaces = split(/,/, $_); @Image = split(/\s+/, $Keyspaces[0]); $ImageID = $Image[$NF - 1]; @Drive = split(/\s+/, $Keyspaces[$NF - 1]); $DriveIndex = $Drive[$NF - 1]; @Media = split(/\s+/, $Keyspaces[3]); $MediaID = $Media[4]; @Frag = split(/\s+/, $Keyspaces[2]); $Fragment = $Frag[$NF - 1]; $Line = sprintf ("%25s %8s %5s %5s", $ImageID, $MediaID, $Fragment, $DriveIndex); } if (grep(/wrote/, $_)) { undef $ImageID2; undef $KB_Written; undef $Speed_Written; @Kspaces = split(/,/, $_); @Image2 = split(/\s+/, $Kspaces[0]); $ImageID2 = $Image2[$NF - 1]; @Frag = split(/\s+/, $Kspaces[2]); $Fragment2 = $Frag[$NF - 1]; if ("$ImageID2" == "$ImageID") { if ("$Fragment2" == "$Fragment") { @Written = split(/\s+/, $Kspaces[3]); $KB_Written = "$Written[1] $Written[2]"; $Speed_Written = "$Written[$NF -2] $Written[$NF - 1]"; $Line2 = sprintf("%-20s %15s", $KB_Written, $Speed_Written); print "$Line $Line2\n"; } } else { # print "\n ERROR: Missing \"begin writing\" line for $ImageID2\n"; ; } } } close(FROM); exit(0);