From 2d6ac00c2daa3dcf044ec19dd0042735530926ba Mon Sep 17 00:00:00 2001 From: savydom <46859196+savydom@users.noreply.github.com> Date: Wed, 30 Mar 2022 21:45:30 -0400 Subject: [PATCH] Add files via upload --- Pete2.pl | 69 + Rebalance_VMware_Clients_to_Groups.pl | 463 ++++++ Savegroup_process.pl | 113 ++ Wed-Wed_Extended_FilesystemTotals.pl | 162 ++ Wed-Wed_FilesystemTotals.pl | 163 ++ Wed-Wed_Full_Totals.pl | 69 + Wed-Wed_Incr_Totals.pl | 70 + Wed-Wed_TapeDisk_Totals.pl | 76 + Wed-Wed_Weekly_Success_Rates.pl | 223 +++ Which_ESX_HOST_Clients_By_Groups.pl | 117 ++ WinCliAudit.pl | 246 +++ check_backup_clients_old.pl | 22 + check_client_groups.pl | 36 + check_filesystem_size.pl | 25 + check_for_program_backups.pl | 49 + check_index_backups.pl | 91 ++ check_networker_authentication_for_clients.pl | 210 +++ check_networker_nsrladb_for_networker.pl | 198 +++ check_number_of_clients_in_groups.pl | 38 + check_number_of_files_backed_up_per_week.pl | 8 + check_tape_locations.pl | 122 ++ check_tapes_to_delete_and_label.pl | 467 ++++++ max_backup_size_per_client_last_month.pl | 88 ++ misc_use_rvtools_snapshot_removal.old.pl | 44 + misc_use_rvtools_snapshot_removal.pl | 45 + misc_use_rvtools_snapshot_removal_VMware60.pl | 45 + misc_use_rvtools_snapshot_removal_manual.pl | 103 ++ missed_full_weekend_backups.pl | 393 +++++ missed_full_weekend_backups20170606.pl | 573 +++++++ missed_full_weekend_backups_2.pl | 269 ++++ missed_full_weekend_backups_no_change.pl | 271 ++++ missed_full_weekend_backups_old.pl | 264 ++++ modsshd_config.pl | 275 ++++ monitor_saves_recovers.pl | 314 ++++ move_groups_from_server_to_server.pl | 121 ++ networker_recovers.pl | 327 ++++ nsr_cli_ver_rpt.pl | 276 ++++ nsr_group_analisys.pl | 314 ++++ nsr_rec_rpt.pl | 402 +++++ nsradmin_tape_performance.pl | 103 ++ nsrsak.pl | 776 +++++++++ ntwkr_client_audit.pl | 212 +++ paraclient.pl | 144 ++ pass_in_clients_to_update_Automated-Groups.pl | 23 + ...nts_to_update_Automated-NON-PROD-Reruns.pl | 19 + pete_screwup.pl | 28 + plotpetesdata.pl | 326 ++++ plotrecovers.pl | 388 +++++ ppp.pl | 3 + preprocess_deleted.pl | 29 + process_aftd.pl | 71 + process_client_AFTD_clone.pl | 71 + process_client_AFTD_clone_20190103.pl | 71 + process_group_completions.pl | 150 ++ process_morning_reports.pl | 1138 +++++++++++++ process_tape_label_list.pl | 139 ++ production_split.pl | 165 ++ put_lines_together.pl | 37 + random_file_using_openssl_rand.pl | 24 + random_file_using_perl_rand.pl | 25 + redistribute_VLANS_to_correct_group.pl | 246 +++ ...tribute_VMware_clients_to_correct_group.pl | 745 +++++++++ remove_old_decom_groups.pl | 29 + reverse_transfer_client.pl | 186 +++ sbh_rpt.pl | 170 ++ search_for_patterns_in_daemon_raw.pl | 65 + show_client_os.pl | 27 + snapcheck.pl | 236 +++ stop_and_start_groups.pl | 188 +++ tapes_expired_per_month.pl | 45 + tapes_to_pull_from_jukebox.pl | 1408 +++++++++++++++++ tapes_to_pull_from_jukebox_20181207.pl | 1404 ++++++++++++++++ tapes_to_recycle_by_pool.pl | 57 + tapes_used_per_week_by_pool.pl | 24 + tapes_used_per_week_subtotaled_by_group.pl | 153 ++ tapes_used_per_year_subtotaled_by_group.pl | 124 ++ test.pl | 5 + test_client_connection.pl | 70 + test_continuations.pl | 108 ++ test_deposit.pl | 6 + test_for_problems.pl | 12 + test_group.pl | 39 + test_pop.pl | 4 + test_signal.pl | 19 + transfer_client.pl | 239 +++ transfer_directives.pl | 55 + transfer_enablers.pl | 34 + transfer_groups.pl | 59 + transfer_label.pl | 55 + transfer_pool.pl | 55 + transfer_schedules.pl | 55 + tst.pl | 9 + ttt.pl | 35 + tut.pl | 210 +++ update_Proxy_backup_host.pl | 32 + update_VM-Name.pl | 202 +++ update_auth_codes.pl | 17 + update_group.pl | 16 + update_servers.pl | 38 + vmware_snap_check.pl | 62 + 100 files changed, 17646 insertions(+) create mode 100644 Pete2.pl create mode 100644 Rebalance_VMware_Clients_to_Groups.pl create mode 100644 Savegroup_process.pl create mode 100644 Wed-Wed_Extended_FilesystemTotals.pl create mode 100644 Wed-Wed_FilesystemTotals.pl create mode 100644 Wed-Wed_Full_Totals.pl create mode 100644 Wed-Wed_Incr_Totals.pl create mode 100644 Wed-Wed_TapeDisk_Totals.pl create mode 100644 Wed-Wed_Weekly_Success_Rates.pl create mode 100644 Which_ESX_HOST_Clients_By_Groups.pl create mode 100644 WinCliAudit.pl create mode 100644 check_backup_clients_old.pl create mode 100644 check_client_groups.pl create mode 100644 check_filesystem_size.pl create mode 100644 check_for_program_backups.pl create mode 100644 check_index_backups.pl create mode 100644 check_networker_authentication_for_clients.pl create mode 100644 check_networker_nsrladb_for_networker.pl create mode 100644 check_number_of_clients_in_groups.pl create mode 100644 check_number_of_files_backed_up_per_week.pl create mode 100644 check_tape_locations.pl create mode 100644 check_tapes_to_delete_and_label.pl create mode 100644 max_backup_size_per_client_last_month.pl create mode 100644 misc_use_rvtools_snapshot_removal.old.pl create mode 100644 misc_use_rvtools_snapshot_removal.pl create mode 100644 misc_use_rvtools_snapshot_removal_VMware60.pl create mode 100644 misc_use_rvtools_snapshot_removal_manual.pl create mode 100644 missed_full_weekend_backups.pl create mode 100644 missed_full_weekend_backups20170606.pl create mode 100644 missed_full_weekend_backups_2.pl create mode 100644 missed_full_weekend_backups_no_change.pl create mode 100644 missed_full_weekend_backups_old.pl create mode 100644 modsshd_config.pl create mode 100644 monitor_saves_recovers.pl create mode 100644 move_groups_from_server_to_server.pl create mode 100644 networker_recovers.pl create mode 100644 nsr_cli_ver_rpt.pl create mode 100644 nsr_group_analisys.pl create mode 100644 nsr_rec_rpt.pl create mode 100644 nsradmin_tape_performance.pl create mode 100644 nsrsak.pl create mode 100644 ntwkr_client_audit.pl create mode 100644 paraclient.pl create mode 100644 pass_in_clients_to_update_Automated-Groups.pl create mode 100644 pass_in_clients_to_update_Automated-NON-PROD-Reruns.pl create mode 100644 pete_screwup.pl create mode 100644 plotpetesdata.pl create mode 100644 plotrecovers.pl create mode 100644 ppp.pl create mode 100644 preprocess_deleted.pl create mode 100644 process_aftd.pl create mode 100644 process_client_AFTD_clone.pl create mode 100644 process_client_AFTD_clone_20190103.pl create mode 100644 process_group_completions.pl create mode 100644 process_morning_reports.pl create mode 100644 process_tape_label_list.pl create mode 100644 production_split.pl create mode 100644 put_lines_together.pl create mode 100644 random_file_using_openssl_rand.pl create mode 100644 random_file_using_perl_rand.pl create mode 100644 redistribute_VLANS_to_correct_group.pl create mode 100644 redistribute_VMware_clients_to_correct_group.pl create mode 100644 remove_old_decom_groups.pl create mode 100644 reverse_transfer_client.pl create mode 100644 sbh_rpt.pl create mode 100644 search_for_patterns_in_daemon_raw.pl create mode 100644 show_client_os.pl create mode 100644 snapcheck.pl create mode 100644 stop_and_start_groups.pl create mode 100644 tapes_expired_per_month.pl create mode 100644 tapes_to_pull_from_jukebox.pl create mode 100644 tapes_to_pull_from_jukebox_20181207.pl create mode 100644 tapes_to_recycle_by_pool.pl create mode 100644 tapes_used_per_week_by_pool.pl create mode 100644 tapes_used_per_week_subtotaled_by_group.pl create mode 100644 tapes_used_per_year_subtotaled_by_group.pl create mode 100644 test.pl create mode 100644 test_client_connection.pl create mode 100644 test_continuations.pl create mode 100644 test_deposit.pl create mode 100644 test_for_problems.pl create mode 100644 test_group.pl create mode 100644 test_pop.pl create mode 100644 test_signal.pl create mode 100644 transfer_client.pl create mode 100644 transfer_directives.pl create mode 100644 transfer_enablers.pl create mode 100644 transfer_groups.pl create mode 100644 transfer_label.pl create mode 100644 transfer_pool.pl create mode 100644 transfer_schedules.pl create mode 100644 tst.pl create mode 100644 ttt.pl create mode 100644 tut.pl create mode 100644 update_Proxy_backup_host.pl create mode 100644 update_VM-Name.pl create mode 100644 update_auth_codes.pl create mode 100644 update_group.pl create mode 100644 update_servers.pl create mode 100644 vmware_snap_check.pl diff --git a/Pete2.pl b/Pete2.pl new file mode 100644 index 0000000..1825f16 --- /dev/null +++ b/Pete2.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl +# $Id:$ +# +# +# +# +########################################################################### +### S P A W A R S h a r e d S e r v i c e s P e t e r R e e d ## +########################################################################### +# +# File: Pete2.pl +# Author: preed +# Date: Wednesday, June 1, 2016 +# +# Generated by bshdr +# Developed by Gene Brandt +# 504 452-3250 +# +########################################################################### +# +# Description: +# This is a second test +# +# +# +########################################################################### +### S P A W A R S h a r e d S e r v i c e s P e t e r R e e d ## +########################################################################### +# Environmentals # +########################################################################### +# +# + + + + +# +# +########################################################################### +### S P A W A R S h a r e d S e r v i c e s P e t e r R e e d ## +########################################################################### +# Processing # +########################################################################### +# +# + + + +# +# +########################################################################### +### S P A W A R S h a r e d S e r v i c e s P e t e r R e e d ## +########################################################################### +# Sub Routines # +########################################################################### +# +# + + + +# +# +########################################################################### +### S P A W A R S h a r e d S e r v i c e s P e t e r R e e d ## +########################################################################### +# House Keeping # +########################################################################### +# +# diff --git a/Rebalance_VMware_Clients_to_Groups.pl b/Rebalance_VMware_Clients_to_Groups.pl new file mode 100644 index 0000000..34f464b --- /dev/null +++ b/Rebalance_VMware_Clients_to_Groups.pl @@ -0,0 +1,463 @@ +#!/usr/bin/perl -w +$plan = @_; + +# Set up email +$MAILADDRS='peter.reed.ctr\@navy.mil jeffrey.l.rodriguez.ctr\@navy.mil ashley.nguyen.ctr\@navy.mil blake.arcement.ctr\@navy.mil cody.p.crawford.ctr\@navy.mil'; +#$MAILADDRS='peter.reed.ctr\@navy.mil'; +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; +$filename = "/home/scriptid/scripts/BACKUPS/REBALANCE/rebalance\_$date"; +open(MAIL,">$filename") or die "Can't open file $filename\n"; +print MAIL "/usr/bin/mailx -s 'Rebalance VADP Groups on both servers ($date)' $MAILADDRS <); + chomp $plan; + } +} +if ($plan =~ /plan/) { + print MAIL "\n\n**************************************************************\n"; + print MAIL " * No changes will be made. This is the plan for the changes *\n"; + print MAIL "**************************************************************\n\n"; +} +unshift (@INC,"/home/scriptid/scripts/BACKUPS/SUBROUTINES"); +require append_group; +require build_output_record; +require create_group_name_from_esx_host_name; +require check_backups_on_other_server; +require handle_nsradmin_line_continuations; +require is_client_running_jobquery; +require pinger; +require read_tabvInfo_old; +require remove_clients_from_group; +require resolv_name; +require start_group; +require stop_group; +require show_group; +require testport; +require update_clients_group; + +# Purpose of utility is to find new clients and to move Windows clients into groups based +# on the blade that they are loaded. We will only move clients that are in the VADP groups. +# If VMware clients are larger than "600GB' they will be backed up under a LARGE group. +# If VMware clients are Linux they go into a normal group. +# The following tags are in the comment field in NetWorker. +# A:; - AFTD +# D:; - decom +# L:; - Linux +# U:; - UNIX +# V:; - Open VMS +# W:; - Windows +# P:; - Production +# I:; - Ignore +# N:; - No Automatic Reruns +# Clients are added to backups if the are up, in DNS, and responding on port 7937 +# Clients are moved if they are in NORMAL, LARGE, or VADP groups. +# Clients can also be moved based on the time that they take to backup. +# NORMAL groups might not be required, thinking they should be merged into the VADP groups helping +# reduce the load on the VMware infrastructure. Needs to be looked at. +# First pass tuning will be to connect all clients in the same group based on their blade. +# Parallelism needs to be determined to minimize snapshot load (we have memory size and disk space size +# and even the LUNs). +# Handle groups as a client update +# +#------------------------------------------------------------------------------------------------------------ +# +$BACKUPSERVER = 'sscprodeng'; +$ALTERNATESERVER = 'sscprodeng2'; # If blank then only uses BACKUPSERVER +(@servers) = ($BACKUPSERVER,$ALTERNATESERVER); + + +################################################################################################################################# +# Set up rap logs to track changes +################################################################################################################################# +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; +open (RAP,">>/home/scriptid/scripts/BACKUPS/RAP/VADP_RAP_$date.log") or die "Could not open /home/scriptid/scripts/BACKUPS/RAP/VADP_RAP_$date.log\n"; + +################################################################################################################################# +# Need to compute totalsize once and only want to compute it on the server on which it is scheduled, it could have been moved + +# Don't need to include on the server machines that are not scheduled, that are Decom'd, that are not VADP +# Nothing this script does changes the above +print MAIL "\n\n*** R e b a l a n c e V M w a r e C l i e n t s t o G r o u p s (Version 3.2.6.0) ***\n\n"; +print MAIL "Check /home/scriptid/scripts/BACKUPS/RAP/VADP_RAP_$date.log for a list of all clients and why they were excluded...\n\n"; +print MAIL "Building list of VADP servers in backups\n"; +foreach $server (@servers) { + $total_server{$server} = 0; + print MAIL "\tBuilding server list for $server\n"; + $nsrpass = ". type:NSR client'\n'show name\\;scheduled backup\\;group\\;backup command\\;action'\n'print"; + (@return) = handle_nsradmin_line_continuations($server,$nsrpass); # Get list back from nsradmin but concatenate long lines like group and comment + print MAIL "\t\tNumber of records returned = $#return\n"; + for ($i=0; $i<=$#return; $i++) { + next if $return[$i] =~ /^\s*$/; # Skip blank lines + if ($return[$i] =~ /name/) { + if ($return[$i+1] =~ /Disabled/) { # Scheduled Backup + print RAP "INFO: Skipped client $return[$i] because it is disabled\n"; + $i+=3; + next; + } + if ($return[$i+2] =~ /DECOM/) { # Group + print RAP "INFO: Skipped client $return[$i] because it is in the DECOMgroup\n"; + $i+=3; + next; + } + if ($return[$i+2] =~ /MIDNIGHT/) { # Group + print RAP "INFO: Skipped client $return[$i] because it is in the MIDNIGHT Group\n"; + $i+=3; + next; + } + if ($return[$i+2] =~ /BigandSlow/) { # Group + print RAP "INFO: Skipped client $return[$i] because it is in the BigandSlow Group\n"; + $i+=3; + next; + } + if ($return[$i+2] =~ /Nuclear/) { # Group + print RAP "INFO: Skipped client $return[$i] because it is in a Nuclear Group\n"; + $i+=3; + next; + } + if ($return[$i+2] =~ /PROBLEMS/) { # Group + print RAP "INFO: Skipped client $return[$i] because it is in the PROBLEMS Group\n"; + $i+=3; + next; + } + + if ($return[$i+2] !~ /VADP/) { # Only process VADP Groups + print RAP "INFO: Skipped client $return[$i] because it's not VADP\n"; + if ($return[$i+2] =~ /group: \;/) { # Group + print RAP "WARN: client $return[$i] is in NO Group on $server and won't be automatically moved\n"; + print MAIL "WARN: client $return[$i] is in NO Group on $server and won't be automatically moved\n"; + print "WARN: client $return[$i] is in NO Group on $server and won't be automatically moved\n"; + } + if ($return[$i+2] =~ /group: INDEX\;/) { # Group + print RAP "WARN: client $return[$i] is only in group INDEX on $server and won't be automatically moved\n"; + print MAIL "WARN: client $return[$i] is only in group INDEX on $server and won't be automatically moved\n"; + print "WARN: client $return[$i] is only in group INDEX on $server and won't be automatically moved\n"; + } + $i+=3; + next; + } + if ($return[$i+3] !~ /nsrvadp_save/) { # backup command + print RAP "INFO: Skipped client $return[$i] because it doesn't have nsrvadp_save set\n"; + $i+=3; + next; + } + + # Save this info + ($client) = ($return[$i] =~ /^.*name: (.*)\;$/); + $client = lc($client); # Lower case clients + if (defined $which_server{$client}) { + print MAIL "ERROR: $client enabled on both backup servers\n"; + $i+=4; + } else { + $which_server{$client} = $server; + $total_server{$server} +=1; + $i+=2; + #chomp $return[$i]; + ($which_group{$client}) = ($return[$i] =~ /^.*group: (.*)\;$/); + $i+=2; + } + } + } + + # Build a list of the max size for each server + (@return) = `/usr/sbin/mminfo -s $server -r 'client,name,totalsize' -q 'level=full,savetime>last month'`; + # This utility is used to determine the maximum size of a client full backup + #print MAIL " Building max backups for clients on $server\n"; + foreach $record (@return) { + next if $record =~ /client/; + chomp $record; + ($client,$name,$totalsize) = split(' ',$record); + next if $name =~ /index/; + next if $totalsize =~ /ROLES/; + next if $totalsize =~ /SYSTEM/; + next if $totalsize =~ /ASR/; + next if $totalsize =~ /FILES/; + next if $totalsize =~ /OTHER/; + next if $totalsize =~ /USER/; + next if $totalsize =~ /DB:/; + next if $totalsize =~ /STATE:/; + #print "$client,$name,$totalsize\n"; + $index = "$client|$name"; # Index is client and filesystem + if (!defined $max{$index} ) { + $max{"$index"} = $ totalsize; + } else { + if ($totalsize > $max{"$index"}) { $max{"$index"} = $totalsize }; + } + } + + # Now process records to determine max full per client + foreach $key (sort keys (%max)) { + ($client,$name) = split(/\|/,$key); + $client = lc($client); + if (!defined $total{$client}) { + $total{$client} = $max{$key}; + } else { + $total{$client} += $max{$key}; + } + } + # total is indexed by lowercase client + + # which_server now contains a list of all clients and which server backs it up. + print MAIL "\t\tThere are $total_server{$server} VADP clients on server $server\n"; +} + +################################################################################################################################# +# Get info from RvTools +# RvTools has all the x86 Virtuals Linux, Windows, VADP backups +# All indexed by lowercase client +print "\nBefore Read of Virtual Center Information\n"; +read_tabvInfo_old(); +print "After Read of Virtual Center Information\n\n"; +################################################################################################################################# +# Process by existing VADP BAckup clients +$count = 0; +$total_VMs = 0; +$return = build_output_record(-80,$output,'CLIENT',18,0,-1,-1 ,'',1,18); +$return = build_output_record(0,$output,'LEVEL',10,0,1,1 ,'',19,29); +$header2= build_output_record(0,$output,'MESSAGE',51,0,0,0 ,'',30,80); +print MAIL "$header2\n"; +our %Host; + +foreach $key (sort keys (%which_server)) { + if ($count == 100) { + $return = build_output_record(-80,$output,'Processing',18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'INFO',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,"*** Virtual Machine $total_VMs ***",51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + $count = 0; + } + $count +=1; + $total_VMs+=1; + if (!defined $Powerstate{$key}) { + $return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'WARN',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,'The Powerstate is undefined',51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + next; + } elsif ($Powerstate{$key} =~ /poweredOff/) { + $return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'WARN',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,'The VM is powered off and will be ignored',51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + next; + } + + # Check to see if the client can be backed up + $dns = resolv_name($key); + if ($dns =~ /Not in DNS/) { + $return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'ERROR',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,'The Client is not in DNS and will be skipped',51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + delete $which_group{$key}; + delete $which_server{$key}; + next; + } elsif ($which_group{$key} =~ /NavyNuclear/ ) { + $return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'INFO',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,'Client in Navy Nuclear group and will be skipped',51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + delete $which_group{$key}; + delete $which_server{$key}; + next; + + } else { + $ping = pinger($key); + if ($ping =~ /up/) { + $port = testport($key,7937); + if ($port =~ 'Client listening') { + ######################################################################################## + # These are tests to determine whether to use VADP or Not + # The server is in DNS is up and listening on the port and it needs to be added + ######################################################################################## + if (!defined $total{$key}) { + $return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'ERROR',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,'The Client is not being backed up',51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + next; + } else { + if ($total{$key} > 644245094400) { + delete $which_group{$key}; + delete $which_server{$key}; + $return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'WARN',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,'Client is > 600GB and will not be moved',51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + next; + } + } + } else { + $port = "Not listening on port 7937"; + $return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'WARN',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,"Client is not listening on port 7937",51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + } + } else { + $return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'WARN',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,"$port, $dns, won't ping",51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + + } + } + # Only trying to find what ESX host the client is on + # $ key is the client, $HOST{$key} is the IP address of the blade the client is on + $hostname = reverse_lookup($Host{$key},$Host{$key}); + if ($hostname =~ /No DNS Name/) { + $return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'ERROR',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,"No DNS entry for blade $Host{$key}",51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + delete $which_group{$key}; + delete $which_server{$key}; + } else { + $hostname =~ s/\..*$//; + ($dest_grpname{$key}) = create_group_name_from_esx_host_name($hostname); + # Check to see the the destination group exists and is enabled + my $nsrpass = ". type: NSR group\\;name:$dest_grpname{$key}'\n'show autostart\\;start time\\;schedule time'\n'print"; + (@return3) = `/usr/bin/echo $nsrpass | /usr/sbin/nsradmin -s $which_server{$key} -i - `; + foreach $vvv (@return3) { + next if $vvv =~ /Current query set/; + if ($vvv =~ /No resources found/) { + $zone = lc $Cluster{$key}; + $zone =~ s/.*zone//; + if ( $zone =~ /^\s*$/) {$zone = 1}; + print RAP "ERROR: The Group $dest_grpname{$key}(Reverse DNS $Host{$key}) Zone $zone for $key doesn't exist on $which_server{$key} and needs to be created\n"; + print MAIL "ERROR: The Group $dest_grpname{$key}(Reverse DNS $Host{$key}) Zone $zone for $key doesn't exist on $which_server{$key} and needs to be created\n"; + last; + } elsif ($vvv =~ /autostart: Disabled/) { + print RAP "ERROR: Group $dest_grpname{$key} isn't enabled but client $key is moved\n"; + print MAIL "ERROR: Group $dest_grpname{$key} isn't enabled but client $key is moved\n"; + last; + } elsif ($vvv =~ /autostart: Disabled/) { + print RAP "ERROR: Group $dest_grpname{$key} isn't enabled but client $key is moved\n"; + print MAIL "ERROR: Group $dest_grpname{$key} isn't enabled but client $key is moved\n"; + last; + } elsif ($vvv =~ /schedule time: \S+\;/) { + print RAP "WARN: Group $dest_grpname{$key} has scheduled time set\n"; + print MAIL "WARN: Group $dest_grpname{$key} has scheduled time set\n"; + last; + } + } + + if ($which_group{$key} =~ /$dest_grpname{$key}/) { + # The destination group matches the source group + delete $which_group{$key}; + delete $which_server{$key}; + #$return = build_output_record(-80,$output,$key,18,0,-1,-1 ,'',1,18); + #$return = build_output_record(0,$output,'INFO',10,0,1,1 ,'',19,29); + #$return = build_output_record(0,$output,"Destination group same as Source no change",51,0,0,0 ,'',30,80); + #print MAIL "$return\n"; + } + + } +} +################################################################################################################################# +print MAIL "\n"; +$return = build_output_record(-106,$output,'CLIENT',18,0,-1,-1 ,'',1,18); +$return = build_output_record(0,$output,'BACKUP SERVER',14,0,1,1 ,'',23,36); +$header2= build_output_record(0,$output,'SOURCE/DESTINATION GROUP',25,0,0,0 ,'',36,106); +print MAIL "$header2\n"; + +$dashes = '-' x 106; +$return = build_output_record(-106,$output,$dashes,106,0,-1,-1 ,'',1,106); +print MAIL "$return\n"; +$i = 0; +foreach $val (sort keys %which_group) { + #print "\n\nKey of which=$val***\n"; + #print "value of which=$which_group{$val}***\n"; + # Host is the ip address of the ESX host + #print "Host=$Host{$val}***\n"; + if (!defined $dest_grpname{$val}) { + #print "Destination group not defined for VM ***$val***\n"; + $dest_grpname{$val} = ' '; + } else { + #print "Destination group name=$dest_grpname{$val}\n"; + } + + #($source_group) = ($which_group{$val} =~ /.*(VADP-\S+)[,;].*$/); + $source_group = $which_group{$val}; + if ($source_group =~ /^\s*$/) { + print MAIL "Source Group undefined or blank\n"; + } + + # Check to see if the destination group is the same as the source group + if ($source_group =~ /$dest_grpname{$val}/) {next}; + + + @source_array = split(/, /,$source_group); + undef @dest_array; + foreach $val (@source_array) { + if ($val =~ /^VADP-/) {next}; + push (@dest_array,$val); + } + + # Make sure that INDEX is in the group + if ( grep(/INDEX/,@dest_array) ) { + # Has INDEX Group nothing required + } else { + push (@dest_array,'INDEX'); + } + + push (@dest_array,$dest_grpname{$val}); + # Put the groups together separated by comma space + $dest_group = join(", ",@dest_array); + + $return = build_output_record(-106,$output,$i,3,0,1,1 ,'',1,3); + $return = build_output_record(0,$output,$val,18,0,-1,-1 ,'',6,23); + $return = build_output_record(0,$output,'SOURCE',10,0,0,0 ,'',24,35); + $return = build_output_record(0,$output,$source_group,70,0,0,0 ,'',36,106); + print MAIL "$return\n"; + + + $return = build_output_record(-106,$output,$which_server{$val},11,0,0,0 ,'',24,35); + $return = build_output_record(0,$output,$dest_group,70,0,0,0 ,'',36,106); + print MAIL "$return\n"; + $i++; + #last if ($i > 120); + # UPDATE CLIENT moving it to new group + if ($plan !~ /plan/) { + #print RAP "INFO: Moved client:$val from group $which_server{$val} to group $dest_group\n"; + print RAP "INFO: Moved client:$val from group sscprodeng2 to group $dest_group\n"; + #update_clients_group ($which_server{$val}, $val, $dest_group); + update_clients_group ($which_server{$val}, $val, $dest_group); + } + $return = build_output_record(-106,$output,$dashes,106,0,-1,-1 ,'',1,106); + print MAIL "$return\n"; +} +print MAIL "ENDMAIL\n"; +$return = `/usr/bin/sh $filename > /dev/null 2>&1`; +close MAIL; +close RAP; + +sub reverse_lookup { + my ($check,$key) = @_; + my $IP = $check; + $name = "No DNS Name"; + if ($IP !~ /\./) { + print MAIL "WARN: No reverse lookup for $key\n"; + } else { + use Socket; + $iaddr = inet_aton("$IP"); + $name = gethostbyaddr($iaddr, AF_INET); + if ( !defined $name ) { + $return = build_output_record(-80,$output,$check,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'ERROR',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,"No reverse lookup for $key",51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + $name = "No DNS Name"; + } + } + return $name; +} + diff --git a/Savegroup_process.pl b/Savegroup_process.pl new file mode 100644 index 0000000..f08a694 --- /dev/null +++ b/Savegroup_process.pl @@ -0,0 +1,113 @@ +#!/usr/bin/perl -w +# This utility will capture output from savegroup completions and then create a data file to be used for processing +# various reports. The records will contain fields semi colon delimited: +# group name +# backup server +# 1 = sscprodeng +# 2 = sscprodeng2 +# start time (time since 1970) +# end time (time since 1970) +# Failed +# Succeeded +# Succeeded with Warnings +# Level + + + + + + + + + + + +# Replace this in Savegroup completion +#tee "/nsr/Summaries/Savegroup`/usr/xpg4/bin/date '+%y%m%d%H%M%S'" | /usr/ucb/mail -s "sscprodeng's savegroup completion" root +#NetWorker savegroup: (alert) SAMBA-SD completed +$input[0] = ; +#print "First before substitute=$input[0]"; +($group) = $input[0] =~ /NetWorker\s+savegroup: \(\w+\) (.+)\s(?:aborted|completed)/; +#Savegroup_process.pl($group) = $input[0] =~ /NetWorker\s+savegroup: \(\w+\) (.+)\bcompleted/; +#print "First=$input[0]"; +#print "Group=$group\n"; +$group =~ s/\s/_/; +$i=0; +$iflag=0; +foreach $line () { + ++$i; + if ($iflag == 0) { + $input[$i] = $line; + if ($line =~ /^Start time: /) { + #print "Line=$line\n"; + #Start time: Sun Mar 29 18:00:00 2009 + ($wday,$mon,$mday,$hr,$min,$sec,$yr) = $line =~ /^Start time:\s+(\w+)\s+(\w+)\s+(\d+)\s(\d+):(\d+):(\d+)\s+(\d+)$/; + $mday = sprintf("%02d",($mday)); + + + #print "Time=$wday,$mon,$mday,$hr,$min,$sec,$yr\n"; + $name="$yr$mon$mday\_$hr$min$sec\_$wday\_$group"; + #print "Time=$name\n"; + open(SUMMARY,">/nsr/Summaries/$name") || die "Could not open output file /nsr/Summaries/$name"; + my $return = `/usr/bin/chmod 664 /nsr/Summaries/$name`; + + for ($j=0;$j<=$i;$j++) { + print SUMMARY $input[$j]; + } + $iflag=1; + } + } else { + print SUMMARY $line; + } +} +# Start Production Virtual after Production Completes +#print Summary "Group=$group\n"; +##if ($group =~ /Production/) { +## $ver=$group; +## $ver =~ s/Production//; +## ($min,$hour,$wday) = (localtime(time))[1,2,6]; +## $min += 5; +## if ($min > 59) { +## $hour += 1; +## $min -= 60; +## # Make sure that the Production group is at least 10 minutes from next day +## } +## $new_start = "$hour:$min"; +## +## # Set level for the run +## $parallelism = 150; +## if ($wday == 0) { +## # Its a Sunday so do a full +## $level = "full"; +## $parallelism = 100; +## } elsif ($wday == 1) { +## # Its a Monday, is it before 2 (arbitrary) +## if ($hour < 2) { +## $level = "full"; +## $parallelism = 100; +## } +## } else { +## # Intent is to have backup levels 8,7,6,5,4 so that a recover is from a full and then a differential +## $level = 9 - $wday; +## } +## +## # Backups to start 5 minutes from now +## open (NSRADMIN,">/tmp/nsradmin_production") or die "Could not open /tmp/nsradmin_production\n"; +## print NSRADMIN ". type:NSR group\;name:Production_Virtual$ver\nupdate start time:\"$new_start\"\nupdate savegrp parallelism:$parallelism\nupdate level:$level\nupdate autostart:Enabled\n"; +## close NSRADMIN; +## $return = `/usr/sbin/nsradmin -i /tmp/nsradmin_production 2>/dev/null`; +## +## # Wait for group to start +## sleep(900); +## +## # Disable +## open (NSRADMIN,">/tmp/nsradmin_production") or die "Could not open /tmp/nsradmin_production\n"; +## print NSRADMIN ". type:NSR group\;name:Production_Virtual$ver\nupdate autostart:Disabled\n"; +## close NSRADMIN; +## $return = `/usr/sbin/nsradmin -i /tmp/nsradmin_production 2>/dev/null`; +##} + +# Add Checks for PAAS groups +# PAAS has multiple servers with the same alias +# Intent is to start PAAS2, 3, 4 in order after PAAS1 completes +# Need to transfer aliases from clients in one group to the next group diff --git a/Wed-Wed_Extended_FilesystemTotals.pl b/Wed-Wed_Extended_FilesystemTotals.pl new file mode 100644 index 0000000..3d3dbd0 --- /dev/null +++ b/Wed-Wed_Extended_FilesystemTotals.pl @@ -0,0 +1,162 @@ +#!/usr/bin/perl -w +# This utility will determine the percent completions for backups. +# First pass is 5 incrementals and 1 full per week + +use Time::Local; +unshift (@INC,"/home/scriptid/scripts/BACKUPS/SUBROUTINES"); +require bit_manip; + + +#%convert_month_to_index = (Jan,0,Feb,1,Mar,2,Apr,3,May,4,Jun,5,Jul,6,Aug,7,Sep,8,Oct,9,Nov,10,Dec,11); +#%convert_month_to_txt = (0,Jan,1,Feb,2,Mar,3,Apr,4,May,5,Jun,6,Jul,7,Aug,8,Sep,9,Oct,10,Nov,11,Dec); + + +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; +#$FAILADDRS='peter.reed.ctr\@navy.mil jeffrey.l.rodriguez.ctr\@navy.mil cody.p.crawford.ctr\@navy.mil'; +#$filename = "/home/scriptid/scripts/BACKUPS/daily_reports/$server\_incr\_$date"; +#open (FAILMAIL,">$filename") or die "Could not open $filename\n"; +#print FAILMAIL "/usr/bin/mailx -s \'Backup Failures for $date on $server\' $FAILADDRS < 6) {$last_wednesday -= 7}; +# Start Seconds is based on Wednesday @ 16:00 +$end_seconds_last_wednesday = $today_16 -$last_wednesday*24*3600; +$start_seconds_previous_wednesday = $end_seconds_last_wednesday-3600*24*7; +print "Start seconds=$start_seconds_previous_wednesday, End Seconds= $end_seconds_last_wednesday\n"; +($day,$mon,$yr) = (localtime($start_seconds_previous_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$start_time = "$mon/$day/$yr 16:00:00"; + +($day,$mon,$yr) = (localtime($end_seconds_last_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$end_time = "$mon/$day/$yr 16:00:00"; + +print "Start time=$start_time, End Time= $end_time\n"; + +# Need to handle special cases for clients running longer than twelve +# Want the start time and the completion time for each day between the previous Wednesday at 16:00 to Thurday at 16:00. +(@return) = `/usr/sbin/mminfo -a -s sscprodeng -xc, -r 'client,name,level,nfiles,totalsize,nsavetime,sscomp(23)' -q 'savetime>$start_time,savetime<$end_time'`; +(@return1) = `/usr/sbin/mminfo -a -s sscprodeng2 -xc, -r 'client,name,level,nfiles,totalsize,nsavetime,sscomp(23)' -q 'savetime>$start_time,savetime<$end_time'`; +push (@return,@return1); +(@return) = sort { lc($a) cmp lc($b) || $a cmp $b } @return; + +# We can now process return updating daily counts for backups +# backup_incr{$client}, backup_full{$client} +# 0 is last Wednesday, 7 is Wednesday +# 0-Last Wednesday, 1-Last Thursday, 2-Last Friday, 3-Last Saturday, 4-Last Sunday, 5-Last Monday, 6-Last Tuesday, 7-Wednesday +# +# day of week = int((nsavetime - last wednesday seconds) / (3600*24) ) +$start = $start_seconds_previous_wednesday; +for $val (@return) { + chomp $val; + my ($client,$filesystem,$level,$number_of_files,$totalsize,$starttime,$end_time) = split(/,/,$val); + ($mon,$mday,$year,$hr,$min,$sec,$AP) = ($end_time =~ /(..)\/(..)\/(..) (\d\d):(\d\d):(\d\d) ?(\D\D)?/); + if (defined $AP) { + if ($AP =~ /PM/) { + if ($hr < 12) {$hr += 12}; + } + } + + $year+= 100; + $mon -=1; + if ($mon < 0) { + print "MON:$val\n"; + next; + } + if ( ($hr < 0) || ($hr > 23) ) { + print "Hr problem $val***\n"; + $hr = 0; + } + + $end_secs = timelocal($sec,$min,$hr,$mday,$mon,$year); + $delta = ($end_secs - $starttime)/3600; + if ($delta > 18) { $slow_client{$client} = 1}; + next if ($client =~ /sscprodeng/); + $day = int( ($starttime - $start) / (3600*24)); + if ($day > 7) { print "Error: $day Date greater than 7\n"}; + if ( $level =~ /[iI][nN][cC][rR]/ ) { + if (!defined $backup_incr{$client}) { $backup_incr{$client} = 0}; + $backup_incr{$client} = bit_manip($backup_incr{$client},$day,0); + if ($delta >18) {$backup_incr{$client} = bit_manip($backup_incr{$client},$day+1,0);} + } elsif ( $level =~ /[fF][uU][lL][lL]/ ) { + if ( !defined $backup_full{$client} ) {$backup_full{$client} = 0}; + $backup_full{$client} = bit_manip($backup_full{$client},$day,0); + } else { + print "Level undefined for Client=$client\n"; + } +} +$ii = 1; +$good = 0; +$bad = 0; +$fulls = 0; +$counti0 = 0; +$counti1 = 0; +$counti2 = 0; +$counti3 = 0; +$counti4 = 0; +$counti5 = 0; +$counti6 = 0; +$counti7 = 0; +$total=0; +foreach $client (sort keys %backup_incr) { + $counti = bit_manip($backup_incr{$client}, 0, 1); + print "$ii\t$client\tINCRS:$counti, "; + if (defined $backup_full{$client}) { + $countf = bit_manip($backup_full{$client}, 0, 1); + print " FULLS:$countf"; + $fulls += 1; + } else { + print "No fulls"; + } + if ($counti > 2 && $countf > 0) { + $good += 1; + } else { + $bad += 1; + } + $ttt = $counti + $countf; + if ($ttt > 4) {$total += 1}; + print "\n"; + ++$ii; + if ($counti == 0) {$counti0 +=1} + if ($counti == 1) {$counti1 +=1} + if ($counti == 2) {$counti2 +=1} + if ($counti == 3) {$counti3 +=1} + if ($counti == 4) {$counti4 +=1} + if ($counti == 5) {$counti5 +=1} + if ($counti == 6) {$counti6 +=1} + if ($counti == 7) {$counti7 +=1} +} +$success = $good/$ii*100; +$fails = $bad/$ii*100; +print "Good:$good, $success\n"; +print " Bad:$bad, $fails\n"; +print " No incrs=$counti0\n"; +print " One incrs=$counti1\n"; +print " Two incrs=$counti2\n"; +print "Three incrs=$counti3\n"; +print " Four incrs=$counti4\n"; +print " Five incrs=$counti5\n"; +print " Six incrs=$counti6\n"; +print "Seven incrs=$counti7\n"; +print "Total Backups = $total\n"; +$slow = scalar keys %slow_client; +print "Slow Clients= $slow\n"; +print "Full client backups = $fulls\n"; diff --git a/Wed-Wed_FilesystemTotals.pl b/Wed-Wed_FilesystemTotals.pl new file mode 100644 index 0000000..f5fdfe6 --- /dev/null +++ b/Wed-Wed_FilesystemTotals.pl @@ -0,0 +1,163 @@ +#!/usr/bin/perl -w +# This utility will determine the percent completions for backups. +# First pass is 5 incrementals and 1 full per week + +use Time::Local; +unshift (@INC,"/home/scriptid/scripts/BACKUPS/SUBROUTINES"); +require bit_manip; + + +#%convert_month_to_index = (Jan,0,Feb,1,Mar,2,Apr,3,May,4,Jun,5,Jul,6,Aug,7,Sep,8,Oct,9,Nov,10,Dec,11); +#%convert_month_to_txt = (0,Jan,1,Feb,2,Mar,3,Apr,4,May,5,Jun,6,Jul,7,Aug,8,Sep,9,Oct,10,Nov,11,Dec); + + +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; +#$FAILADDRS='peter.reed.ctr\@navy.mil jeffrey.l.rodriguez.ctr\@navy.mil cody.p.crawford.ctr\@navy.mil'; +#$filename = "/home/scriptid/scripts/BACKUPS/daily_reports/$server\_incr\_$date"; +#open (FAILMAIL,">$filename") or die "Could not open $filename\n"; +#print FAILMAIL "/usr/bin/mailx -s \'Backup Failures for $date on $server\' $FAILADDRS < 6) {$last_wednesday -= 7}; +# Start Seconds is based on Wednesday @ 16:00 +$end_seconds_last_wednesday = $today_16 -$last_wednesday*24*3600; +$start_seconds_previous_wednesday = $end_seconds_last_wednesday-3600*24*7; +print "Start seconds=$start_seconds_previous_wednesday, End Seconds= $end_seconds_last_wednesday\n"; +($day,$mon,$yr) = (localtime($start_seconds_previous_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$start_time = "$mon/$day/$yr 16:00:00"; + +($day,$mon,$yr) = (localtime($end_seconds_last_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$end_time = "$mon/$day/$yr 16:00:00"; + +print "Start time=$start_time, End Time= $end_time\n"; + +# Need to handle special cases for clients running longer than twelve +# Want the start time and the completion time for each day between the previous Wednesday at 16:00 to Thurday at 16:00. +(@return) = `/usr/sbin/mminfo -a -s sscprodeng -xc, -r 'client,name,level,nfiles,totalsize,nsavetime,sscomp(23)' -q 'savetime>$start_time,savetime<$end_time'`; +(@return1) = `/usr/sbin/mminfo -a -s sscprodeng2 -xc, -r 'client,name,level,nfiles,totalsize,nsavetime,sscomp(23)' -q 'savetime>$start_time,savetime<$end_time'`; +push (@return,@return1); +(@return) = sort { lc($a) cmp lc($b) || $a cmp $b } @return; + +# We can now process return updating daily counts for backups +# backup_incr{$client}, backup_full{$client} +# 0 is last Wednesday, 7 is Wednesday +# 0-Last Wednesday, 1-Last Thursday, 2-Last Friday, 3-Last Saturday, 4-Last Sunday, 5-Last Monday, 6-Last Tuesday, 7-Wednesday +# +# day of week = int((nsavetime - last wednesday seconds) / (3600*24) ) +$start = $start_seconds_previous_wednesday; +$end = $end_seconds_last_wednesday; +for $val (@return) { + chomp $val; + ($client,$filesystem,$level,$number_of_files,$totalsize,$starttime,$end_time) = split(/,/,$val); + ($mon,$mday,$year,$hr,$min,$sec,$AP) = ($end_time =~ /(..)\/(..)\/(..) (\d\d):(\d\d):(\d\d) ?(\D\D)?/); + if (defined $AP) { + if ($AP =~ /PM/) { + if ($hr < 12) {$hr += 12}; + } + } + + $year+= 100; + $mon -=1; + if ($mon < 0) { + print "MON:$val\n"; + next; + } + if ( ($hr < 0) || ($hr > 23) ) { + print "Hr problem $val***\n"; + $hr = 0; + } + + $end_secs = timelocal($sec,$min,$hr,$mday,$mon,$year); + $delta = ($end_secs - $starttime)/3600; + if ($delta > 18) { $slow_client{$client} = 1}; + next if ($client =~ /sscprodeng/); + $day = int( ($starttime - $start) / (3600*24)); + if ($day > 7) { print "Error: $day Date greater than 7\n"}; + if ( $level =~ /[iI][nN][cC][rR]/ ) { + if (!defined $backup_incr{$client}) { $backup_incr{$client} = 0}; + $backup_incr{$client} = bit_manip($backup_incr{$client},$day,0); + if ($delta >18) {$backup_incr{$client} = bit_manip($backup_incr{$client},$day+1,0);} + } elsif ( $level =~ /[fF][uU][lL][lL]/ ) { + if ( !defined $backup_full{$client} ) {$backup_full{$client} = 0}; + $backup_full{$client} = bit_manip($backup_full{$client},$day,0); + } else { + print "Level undefined for Client=$client\n"; + } +} +$ii = 1; +$good = 0; +$bad = 0; +$fulls = 0; +$counti0 = 0; +$counti1 = 0; +$counti2 = 0; +$counti3 = 0; +$counti4 = 0; +$counti5 = 0; +$counti6 = 0; +$counti7 = 0; +$total=0; +foreach $client (sort keys %backup_incr) { + $counti = bit_manip($backup_incr{$client}, 0, 1); + print "$ii\t$client\tINCRS:$counti, "; + if (defined $backup_full{$client}) { + $countf = bit_manip($backup_full{$client}, 0, 1); + print " FULLS:$countf"; + $fulls += 1; + } else { + print "No fulls"; + } + if ($counti > 2 && $countf > 0) { + $good += 1; + } else { + $bad += 1; + } + $ttt = $counti + $countf; + if ($ttt > 4) {$total += 1}; + print "\n"; + ++$ii; + if ($counti == 0) {$counti0 +=1} + if ($counti == 1) {$counti1 +=1} + if ($counti == 2) {$counti2 +=1} + if ($counti == 3) {$counti3 +=1} + if ($counti == 4) {$counti4 +=1} + if ($counti == 5) {$counti5 +=1} + if ($counti == 6) {$counti6 +=1} + if ($counti == 7) {$counti7 +=1} +} +$success = $good/$ii*100; +$fails = $bad/$ii*100; +print "Good:$good, $success\n"; +print " Bad:$bad, $fails\n"; +print " No incrs=$counti0\n"; +print " One incrs=$counti1\n"; +print " Two incrs=$counti2\n"; +print "Three incrs=$counti3\n"; +print " Four incrs=$counti4\n"; +print " Five incrs=$counti5\n"; +print " Six incrs=$counti6\n"; +print "Seven incrs=$counti7\n"; +print "Total Backups = $total\n"; +$slow = scalar keys %slow_client; +print "Slow Clients= $slow\n"; +print "Full client backups = $fulls\n"; diff --git a/Wed-Wed_Full_Totals.pl b/Wed-Wed_Full_Totals.pl new file mode 100644 index 0000000..610d68d --- /dev/null +++ b/Wed-Wed_Full_Totals.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl -w +# This utility is used to find the unremediated backups since 16:00 yesterday. +# This is used to create an automated rerun at 4:00 in the morning +# passing print to the script with just report and not update the group + +use Time::Local; +#%convert_month_to_index = (Jan,0,Feb,1,Mar,2,Apr,3,May,4,Jun,5,Jul,6,Aug,7,Sep,8,Oct,9,Nov,10,Dec,11); +#%convert_month_to_txt = (0,Jan,1,Feb,2,Mar,3,Apr,4,May,5,Jun,6,Jul,7,Aug,8,Sep,9,Oct,10,Nov,11,Dec); +if (defined $ARGV[0] ) { + $server = $ARGV[0]; +} else { + $server = `/usr/bin/hostname`; + chomp $server; +} + +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; + +#$FAILADDRS='peter.reed.ctr\@navy.mil jeffrey.l.rodriguez.ctr\@navy.mil cody.p.crawford.ctr\@navy.mil'; +#$FAILADDRS='peter.reed.ctr\@navy.mil'; +#$filename = "/home/scriptid/scripts/BACKUPS/daily_reports/$server\_full\_$date"; +#print "Output filename=$filename\n"; +#open (FAILMAIL,">$filename") or die "Could not open $filename\n"; +#print FAILMAIL "/usr/bin/mailx -s \'Backup Failures for $date on $server\' $FAILADDRS < 10) {$last_wednesday -= 7}; +# Start Seconds is based on Wednesday @ 16:00 +$end_seconds_last_wednesday = $today_16 -$last_wednesday*24*3600; +$start_seconds_previous_wednesday = $end_seconds_last_wednesday-3600*24*7; +#print "Start seconds=$start_seconds_previous_wednesday, End Seconds= $end_seconds_last_wednesday\n"; +($day,$mon,$yr) = (localtime($start_seconds_previous_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$start_time = "$mon/$day/$yr 16:00:00"; + +($day,$mon,$yr) = (localtime($end_seconds_last_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$end_time = "$mon/$day/$yr 16:00:00"; +#print "Start time=$start_time, End Time= $end_time\n"; +(@return) = `/usr/sbin/mminfo -s $server -r totalsize -q 'level=full,savetime>$start_time,savetime<$end_time'`; +$total = 0; +foreach $val (@return) { + chomp $val; + $total += $val; +} +$out = $total/1024/1024/1024/1024; +if (defined $ARGV[1]) { + print "$out\n"; +} else { + print "Total Full backups = $out\n"; +} + diff --git a/Wed-Wed_Incr_Totals.pl b/Wed-Wed_Incr_Totals.pl new file mode 100644 index 0000000..079c394 --- /dev/null +++ b/Wed-Wed_Incr_Totals.pl @@ -0,0 +1,70 @@ +#!/usr/bin/perl -w +# This utility is used to find the unremediated backups since 16:00 yesterday. +# This is used to create an automated rerun at 4:00 in the morning +# passing print to the script with just report and not update the group + +use Time::Local; +#%convert_month_to_index = (Jan,0,Feb,1,Mar,2,Apr,3,May,4,Jun,5,Jul,6,Aug,7,Sep,8,Oct,9,Nov,10,Dec,11); +#%convert_month_to_txt = (0,Jan,1,Feb,2,Mar,3,Apr,4,May,5,Jun,6,Jul,7,Aug,8,Sep,9,Oct,10,Nov,11,Dec); +if (defined $ARGV[0] ) { + $server = $ARGV[0]; +} else { + $server = `/usr/bin/hostname`; + chomp $server; +} + +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; +my $networker = `/usr/bin/hostname`; +chomp $networker; +#$FAILADDRS='peter.reed.ctr\@navy.mil jeffrey.l.rodriguez.ctr\@navy.mil cody.p.crawford.ctr\@navy.mil'; +#$FAILADDRS='peter.reed.ctr\@navy.mil'; +#filename = "/home/scriptid/scripts/BACKUPS/daily_reports/$networker\_incr\_$date"; +#print "Output filename=$filename\n"; +#open (FAILMAIL,">$filename") or die "Could not open $filename\n"; +#print FAILMAIL "/usr/bin/mailx -s \'Backup Failures for $date on $networker\' $FAILADDRS < 10) {$last_wednesday -= 7}; +# Start Seconds is based on Wednesday @ 16:00 +$end_seconds_last_wednesday = $today_16 -$last_wednesday*24*3600; +$start_seconds_previous_wednesday = $end_seconds_last_wednesday-3600*24*7; +#print "Start seconds=$start_seconds_previous_wednesday, End Seconds= $end_seconds_last_wednesday\n"; +($day,$mon,$yr) = (localtime($start_seconds_previous_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$start_time = "$mon/$day/$yr 16:00:00"; + +($day,$mon,$yr) = (localtime($end_seconds_last_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$end_time = "$mon/$day/$yr 16:00:00"; +#print "Start time=$start_time, End Time= $end_time\n"; +(@return) = `/usr/sbin/mminfo -s $server -r totalsize -q 'level=incr,savetime>$start_time,savetime<$end_time'`; +$total = 0; +foreach $val (@return) { + chomp $val; + $total += $val; +} +$out = $total/1024/1024/1024/1024; +if (defined $ARGV[1]) { + print "$out\n";; +} else { + print "Total Full backups = $out\n"; +} + diff --git a/Wed-Wed_TapeDisk_Totals.pl b/Wed-Wed_TapeDisk_Totals.pl new file mode 100644 index 0000000..94398cc --- /dev/null +++ b/Wed-Wed_TapeDisk_Totals.pl @@ -0,0 +1,76 @@ +#!/usr/bin/perl -w +# This utility is used to find the unremediated backups since 16:00 yesterday. +# This is used to create an automated rerun at 4:00 in the morning +# passing print to the script with just report and not update the group + +use Time::Local; +#%convert_month_to_index = (Jan,0,Feb,1,Mar,2,Apr,3,May,4,Jun,5,Jul,6,Aug,7,Sep,8,Oct,9,Nov,10,Dec,11); +#%convert_month_to_txt = (0,Jan,1,Feb,2,Mar,3,Apr,4,May,5,Jun,6,Jul,7,Aug,8,Sep,9,Oct,10,Nov,11,Dec); +if (defined $ARGV[0] ) { + $server = $ARGV[0]; +} else { + $server = `/usr/bin/hostname`; + chomp $server; +} + +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; +#$FAILADDRS='peter.reed.ctr\@navy.mil jeffrey.l.rodriguez.ctr\@navy.mil cody.p.crawford.ctr\@navy.mil'; +#$FAILADDRS='peter.reed.ctr\@navy.mil'; +#$filename = "/home/scriptid/scripts/BACKUPS/daily_reports/$server\_incr\_$date"; +#print "Output filename=$filename\n"; +#open (FAILMAIL,">$filename") or die "Could not open $filename\n"; +#print FAILMAIL "/usr/bin/mailx -s \'Backup Failures for $date on $server\' $FAILADDRS < 10) {$last_wednesday -= 7}; +# Start Seconds is based on Wednesday @ 16:00 +$end_seconds_last_wednesday = $today_16 -$last_wednesday*24*3600; +$start_seconds_previous_wednesday = $end_seconds_last_wednesday-3600*24*7; +#print "Start seconds=$start_seconds_previous_wednesday, End Seconds= $end_seconds_last_wednesday\n"; +($day,$mon,$yr) = (localtime($start_seconds_previous_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$start_time = "$mon/$day/$yr 16:00:00"; + +($day,$mon,$yr) = (localtime($end_seconds_last_wednesday))[3,4,5]; +$mon += 1; +#$mon = $convert_month_to_txt{$mon}; +$yr += 1900; +$end_time = "$mon/$day/$yr 16:00:00"; + +#print "Start time=$start_time, End Time= $end_time\n"; +#print "/usr/sbin/mminfo -xc, -r volume,type -q 'savetime>$start_time,savetime<$end_time'\n"; +(@return) = `/usr/sbin/mminfo -s $server -xc, -r volume,type -q 'savetime>$start_time,savetime<$end_time'`; +$volumes{'LTO Ultrium-5'} = 0; +$volumes{'adv_file'} = 0; +my $volume; +foreach $val (@return) { + next if $val =~ /volume,type/; + chomp $val; + #print "Val=$val\n"; + ($volume,$type) = split(/,/,$val); + $volumes{$type} += 1 +} +if (defined $ARGV[1]) { + print "$volumes{'LTO Ultrium-5'},$volumes{'adv_file'}\n"; +} else { + print "Start:$start_time\n"; + print "End:$end_time\n"; + print "Total LTO Ultrium-5:$volumes{'LTO Ultrium-5'}\n"; + print "Total DISK:$volumes{'adv_file'}\n"; +} diff --git a/Wed-Wed_Weekly_Success_Rates.pl b/Wed-Wed_Weekly_Success_Rates.pl new file mode 100644 index 0000000..168be23 --- /dev/null +++ b/Wed-Wed_Weekly_Success_Rates.pl @@ -0,0 +1,223 @@ +#!/usr/bin/perl -w +# This utility is used to find the unremediated backups since 16:00 yesterday. +# This is used to create an automated rerun at 4:00 in the morning +# passing print to the script with just report and not update the group + +use Time::Local; +%convert_month_to_index = (Jan,0,Feb,1,Mar,2,Apr,3,May,4,Jun,5,Jul,6,Aug,7,Sep,8,Oct,9,Nov,10,Dec,11); + #%convert_month_to_txt = (0,Jan,1,Feb,2,Mar,3,Apr,4,May,5,Jun,6,Jul,7,Aug,8,Sep,9,Oct,10,Nov,11,Dec); + #%convert_month = (Jan,0,Feb,1,Mar,2,Apr,3,May,4,Jun,5,Jul,6,Aug,7,Sep,8,Oct,9,Nov,10,Dec,11); +if (defined $ARGV[0] ) { + $server = $ARGV[0]; +} else { + $server = `/usr/bin/hostname`; + chomp $server; +} + + +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; +#$FAILADDRS='peter.reed.ctr\@navy.mil jeffrey.l.rodriguez.ctr\@navy.mil cody.p.crawford.ctr\@navy.mil'; +#$FAILADDRS='peter.reed.ctr\@navy.mil'; +#$filename = "/home/scriptid/scripts/BACKUPS/daily_reports/$server\_$date"; +#open (FAILMAIL,">$filename") or die "Could not open $filename\n"; +#print FAILMAIL "/usr/bin/mailx -s \'Backup Failures for $date on $server\' $FAILADDRS < 10) {$last_wednesday -= 7}; +# Start Seconds is based on Wednesday @ 16:00 +$start_seconds_last_wednesday = $today_16 -$last_wednesday*24*3600; + +# The find command will locate files based on the date the runs completed not the time they were started +$last_tuesday = $last_wednesday +1; + +#/backup/nsr/Summaries/2017May16_001200_Tue_VADP-Prodspec-Ch1-620-B9 +#/backup/nsr/Summaries/2017May16_003300_Tue_VADP-Devpriv-Ch2-910-B3 +#/backup/nsr/Summaries/2017May15_184800_Mon_VADP-Transqa-Ch1-610-B4 +# Get a list of all the files created from last Tuesday, Because of the sort as soon as date is past end date can stop loop +(@savegroups) = `$SUDO /usr/bin/find /backup/nsr/Summaries -type f -mtime -$last_tuesday -exec /usr/bin/ls -1 \{\} \\\; | /usr/bin/sort`; +$SUCCEEDED_WITH_WARNINGS=$SUCCEEDED=$FAILED=$max_clients=0; +for ($i=0; $i<7; $i++) { + $start_seconds = $start_seconds_last_wednesday+24*3600*$i; + $end_seconds = $start_seconds + 3600*24; + + # Build a list of files to process + undef %warning; + undef %test; + foreach $val (@savegroups) { + next if ($val =~ /INDEX/); + chomp $val; + ($year,$month,$mday,$hr,$min,$sec) = ($val =~ /\/backup\/nsr\/Summaries\/(\d\d\d\d)(\D\D\D)(\d\d)\_(\d\d)(\d\d)(\d\d)/); + #print "$year,$month,$mday,$hr,$min,$sec "; + $year -= 1900; + $month = $convert_month_to_index{$month}; + $file_time_secs = timelocal($sec,$min,$hr,$mday,$month,$year); + #print "File time Seconds:$file_time_secs, $start_seconds, $end_seconds\n"; + next if $file_time_secs < $start_seconds; + last if $file_time_secs > $end_seconds; + #print "Processing $val\n"; + (@return) = `/usr/bin/cat $val\"`; + $failed=$succeeded_with_warnings=$succeeded=$start_time=$end_time=' '; + foreach $line (@return) { + chomp $line; + if ($line =~ /^Failed:/) { + $failed = $line; + $failed =~ s/Failed: //; + } elsif ($line =~ /^Succeeded with warning\(s\):/) { + $succeeded_with_warnings = $line; + $succeeded_with_warnings =~ s/Succeeded with warning\(s\): //; + #print "/n/nSucceeded_with_warning*****=$succeeded_with_warnings\n"; + } elsif ($line =~ /^Succeeded:/) { + $succeeded = $line; + $succeeded =~ s/Succeeded: //; + } elsif ($line =~ /^Start time:/) { + $start_time = $line; + $start_time =~ s/Start time: //; + } elsif ($line =~ /^End time:/) { + $end_time = $line; + $end_time =~ s/End time:\s+//; + #End time: Mon May 15 21:56:00 2017 + ($wday,$mon,$mday,$hr,$min,$sec,$year) = ($end_time =~ /(\D\D\D)\s(\D\D\D)\s(\d\d)\s(\d\d)\:(\d\d)\:(\d\d)\s(\d\d\d\d)/); + $mon = $convert_month_to_index{$mon}; + $year -= 1900; + $status_time_secs = timelocal($sec,$min,$hr,$mday,$mon,$year); + } else { + + } + } + + (@succeeded) = split(/, /,$succeeded); + (@fails) = split(/, /,$failed); + (@succeeded_with_warning) = split(/, /,$succeeded_with_warnings); + #print "Succeeded=@succeeded\n"; + #print "Fails=@fails\n"; + #print "Succeeded_with_warning*****=@succeeded_with_warning\n"; + + foreach $val1 (@succeeded) { + chomp $val1; + next if $val1 =~ /^\s*$/; + if (defined $test{$val1}) { + if ( $status_time_secs > $test{$val1} ) { + # Completed came after failed or rerun at a later time + $test{$val1} = $status_time_secs; + #print "In defined succeeded $val1, $test{$val1}\n"; + } + } else { + $test{$val1} = $status_time_secs; + #print "In undefined succeeded $val1, $test{$val1}\n"; + } + #print "Succeeded=$val1\n"; + } + foreach $val1 (@succeeded_with_warning) { + chomp $val1; + next if $val1 =~ /^\s*$/; + if ( defined $test{$val1} ) { + if ( $status_time_secs > $test{$val1} ) { + # Completed came after failed or rerun at a later time + $test{$val1} = $status_time_secs; + $warning{$val1} = $status_time_secs; + #print "warning=$val1, $warning{$val1}\n"; + } + } else { + $test{$val1} = $status_time_secs; + $warning{$val1} = $status_time_secs; + #print "warning=$val1, $warning{$val1}\n"; + } + #print "Succeeded with warning=$val1\n"; + + } + foreach $val1 (@fails) { + chomp $val1; + next if $val1 =~ /^\s*$/; + if ( defined $test{$val1} ) { + if ( $status_time_secs > abs($test{$val1}) ) { + # Failed came after succeeded or rerun at a later time + $test{$val1} = - $status_time_secs; + #print "warning=$val1, undef\n"; + undef $warning{$val1}; + } + } else { + $test{$val1} = - $status_time_secs; + #print "warning=$val1, undef\n"; + undef $warning{$val1}; + } + #print "Failed=$val1\n"; + } + } + $counter = keys %test; + #print "Daily Number of Clients=$counter\n"; + if ($counter > $max_clients) {$max_clients=$counter}; + + + +# ****************************** Process Daily Totals **************************************** + + # Check to see which clients are scheduled + #my $run = is_client_scheduled($server); + + foreach $val (sort keys %test) { + #print "Keys=$val\n"; + #if ( defined $scheduled_backup{$val} ) { + if ($test{$val} < 0) { + $FAILED += 1; + } else { + if (defined $warning{$val}) { + #print "SUCCEEDED_WITH_WARNINGS=$val, $warning{$val}\n"; + $SUCCEEDED_WITH_WARNINGS += 1; + } else { + $SUCCEEDED += 1; + } + } + #} + } + +# End of day loop +} +$TOTAL = $SUCCEEDED+$SUCCEEDED_WITH_WARNINGS+$FAILED; +if (defined $ARGV[1]) { + print "$max_clients,$TOTAL,$SUCCEEDED,$SUCCEEDED_WITH_WARNINGS,$FAILED\n"; +} else { + print " S E R V E R = $server\n"; + print " Maximum Number of Clients: $max_clients\n"; + print " Total CLient Backups: $TOTAL\n"; + $percent = $SUCCEEDED/$TOTAL*100; + print " Succeeded: $SUCCEEDED, $percent\n"; + $percent = $SUCCEEDED_WITH_WARNINGS/$TOTAL*100; + print " Succeeded with Warnings: $SUCCEEDED_WITH_WARNINGS, $percent\n"; + $percent = $FAILED/$TOTAL*100; + print " Failed: $FAILED, $percent\n"; +} + +sub is_client_scheduled { + $nsrpass = ". type:NSR client'\n'show name\\;scheduled backup'\n'print"; + (@return) = `/usr/bin/echo $nsrpass | /usr/sbin/nsradmin -i -`; + # Client name is mixed case so lower case the names + foreach $val (@return) { + chomp $val; + $val =~ s/\;//; + next if $val =~ /^\s*$/; + if ($val =~ /name:/) { + $val =~ s/\s*name: //; + #$name = lc($val); + $name = $val; + } elsif ($val =~ /scheduled backup/) { + $val =~ s/\s*scheduled backup: //; + $scheduled_backup{$name} = $val; + } + + } + return %scheduled_backup; +} diff --git a/Which_ESX_HOST_Clients_By_Groups.pl b/Which_ESX_HOST_Clients_By_Groups.pl new file mode 100644 index 0000000..7528e8f --- /dev/null +++ b/Which_ESX_HOST_Clients_By_Groups.pl @@ -0,0 +1,117 @@ +#!/usr/bin/perl -w +unshift (@INC,"/home/scriptid/scripts/BACKUPS/SUBROUTINES"); +require append_group; +require build_output_record; +require create_group_name_from_esx_host_name; +require check_backups_on_other_server; +require handle_nsradmin_line_continuations; +require is_client_running_jobquery; +require pinger; +require read_tabvInfo_old; +require remove_clients_from_group; +require resolv_name; +require start_group; +require stop_group; +require show_group; +require testport; +require update_clients_group; + +# Purpose of utility is to display the ESX Hostname for each client in a speacific group +# +#------------------------------------------------------------------------------------------------------------ +# +$BACKUPSERVER = 'sscprodeng'; +$ALTERNATESERVER = 'sscprodeng2'; # If blank then only uses BACKUPSERVER +(@servers) = ($BACKUPSERVER,$ALTERNATESERVER); + + +################################################################################################################################# +# Set up rap logs to track changes +################################################################################################################################# +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; +open (RAP,">>/home/scriptid/scripts/BACKUPS/RAP/WESXH_RAP_$date.log") or die "Could not open /home/scriptid/scripts/BACKUPS/RAP/WESXH_RAP_$date.log\n"; + +################################################################################################################################# +# Need to compute totalsize once and only want to compute it on the server on which it is scheduled, it could have been moved + +# Don't need to include on the server machines that are not scheduled, that are Decom'd, that are not VADP +# Nothing this script does changes the above + +################################################################################################################################# +# Get info from RvTools +# RvTools has all the x86 Virtuals Linux, Windows, VADP backups +# All indexed by lowercase client +print "\nBefore Read of Virtual Center Information\n"; +read_tabvInfo_old(); +print "After Read of Virtual Center Information\n\n"; +################################################################################################################################# + + +foreach $server (@servers) { + # Build a list of the max size for each server + (@return) = `/usr/sbin/mminfo -s $server -xc, -r 'client,group' -q 'level=full,savetime>last month' | /usr/bin/sort | /usr/bin/uniq`; + #print MAIL " Building list of clients and their groups on $server\n"; + foreach $record (@return) { + next if $record =~ /client/; + chomp $record; + ($client,$group) = split(/,/,$record); + $client = lc $client; + $groups{$client} = $group; + } +} + +#foreach $val (keys %groups) { +# print "Client:$val, ESX_HOST=$Host{$val}\n"; +#} +TOP: +print "Enter networker group name to search or all: "; +$search = ; +chomp $search; +foreach $val (sort keys %DNS_Name) { + $client = $DNS_Name{$val}; + $client =~ s/\.\S+$//; + $client = lc $client; + next if $client =~ /^\s*$/; + next if $client =~ /^\d/; + $dns = resolv_name($val); + if ($dns =~ /Not in DNS/) { + #print "WARN: VM $client not in DNS\n"; + } else { + $hostname = reverse_lookup($Host{$val},$Host{$val}); + #if ($client =~ /mfom/) { + # print "Client=$client, Group=$groups{$client}, Host=$hostname\n"; + #} + if (defined $groups{$client}) { + if ($groups{$client} =~ /$search/ || (lc $search =~ /^all$/)) { + print "Client=$client, Group=$groups{$client}, Host=$hostname\n"; + } + } else { + #print "Networker Group not defined for $client\n"; + } + } +} + + + +sub reverse_lookup { + my ($check,$key) = @_; + my $IP = $check; + $name = "No DNS Name"; + if ($IP !~ /\./) { + print MAIL "WARN: No reverse lookup for $key\n"; + } else { + use Socket; + $iaddr = inet_aton("$IP"); + $name = gethostbyaddr($iaddr, AF_INET); + if ( !defined $name ) { + $return = build_output_record(-80,$output,$check,18,0,-1,-1 ,'',1,18); + $return = build_output_record(0,$output,'ERROR',10,0,1,1 ,'',19,29); + $return = build_output_record(0,$output,"No reverse lookup for $key",51,0,0,0 ,'',30,80); + print MAIL "$return\n"; + $name = "No DNS Name"; + } + } + return $name; +} + diff --git a/WinCliAudit.pl b/WinCliAudit.pl new file mode 100644 index 0000000..69cfd2a --- /dev/null +++ b/WinCliAudit.pl @@ -0,0 +1,246 @@ +#!/bin/perl +# $Id:$ +# +# +# +# +########################################################################## +############### S P A W A R S H A R E D S E R V I C E S ############ +########################################################################## +# +# File: WinCliAudit.pl +# Author: gbrandt +# Date: Wednesday, July 17, 2013 +# +########################################################################## +# +# Description: +# Windows Client Audit +# +# +# +############### S P A W A R S H A R E D S E R V I C E S ############ +########################################################################## +# +# Invocation: +# +# +# +########################################################################## +# +# Revisions: +# +# +# $Log:$ +# +# +########################################################################## +########################################################################## + +# +# +############### S P A W A R S H A R E D S E R V I C E S ############ +########################################################################## +# Environmentals # +########################################################################## +# +# + +$WCAQRYNAME = "/tmp/wcaqry$$"; +$MAXLINE = 60; +$LineCount = $MAXLINE + 1; +$PageCount = 0; +$RPTDATE = `date '+%m/%d/%Y'`; +$RPTTIME = `date '+%H:%M:%S'`; + +# +# +############### S P A W A R S H A R E D S E R V I C E S ############ +########################################################################## +# Processing # +########################################################################## +# +# + +# +# Evaluate command line. +# + +if ( $#ARGV < 0 ) +{ + printf "\n\n Usage: $0 server_name \n\n"; + printf +" Displays a report of a Windows client's Networker versioa.n If an additional file\n"; + printf +" is entered, a csv file is generated. The \".csv\" will be appended to the filename entered.\n\n"; + exit(1); +} +if ( $#ARGV == 1 ) +{ + $CSVNAME = $ARGV[1]; + $CSVNAME .= ".csv"; + printf "Creating file: %s\n", $CSVNAME; + open( CSV, ">$CSVNAME" ) || die "Can't open $CSVNAME $!.\n\n:"; +} +$Server = $ARGV[0]; + +chomp($RPTDATE); +chomp($RPTTIME); +# +# Compose query. +# + +open( QRY, ">$WCAQRYNAME" ) || die "Can't open $WCAQRYNAME $!\n\n"; +printf QRY "option regexp\n"; +printf QRY ". type:nsr client;client OS type: Win.*;scheduled backup:enabled\n"; +printf QRY "show name;client OS type;NetWorker version\n"; +printf QRY "print\n"; +close(QRY); + +$QryCmd = "nsradmin -s $Server -i $WCAQRYNAME|"; +open( QRY, $QryCmd ) || die "Can't run $QryCmd $!\n"; +$ClientCount = 0; +while () +{ + chomp(); + tr /;//d; +# +# Skip the opening lines that describe the query. +# + if ( /Display/ + || /Dynamic/ + || /Hidden/ + || /Raw/ + || /Resource/ + || /Regexp/ + || /Current/ ) + { + next; + } + if (/name/) + { + @NAME = split(/:/); + $ClientName[$ClientCount] = $NAME[1]; + next; + } + if (/client/) + { + @OS = split(/:/); + if ( length( $OS[1] ) > 2 ) + { + $ClientOS[$ClientCount] = $OS[1]; + } + else + { + $ClientOS[$ClientCount] = "Unknown"; + } + next; + } + if (/NetWorker/) + { + @VERSION = split(/:/); + if ( length( $VERSION[1] ) > 2 ) + { + $ClientVersion[$ClientCount] = $VERSION[1]; + } + else + { + $ClientVersion[$ClientCount] = " Unknown"; + } + +# printf "%23s ",$ClientName[$ClientCount]; +# printf "%35s ",$ClientOS[$ClientCount]; +# printf "%s\n",$ClientVersion[$ClientCount]; + $ClientCount++; + +# $LineCount++; + next; + } +} +# +# Sort data for easier reading. +# + +foreach $SortedClient ( sort (@ClientName) ) +{ + $Sortcount = 0; + foreach $Client (@ClientName) + { + if ( $Client eq $SortedClient ) + { + if ( $LineCount > $MAXLINE ) + { + if ( $#ARGV != 1 ) + { + page_header(); + } + } + if ( $#ARGV != 1 ) + { + printf "%23s %35s %s\n", $SortedClient, + $ClientOS[$Sortcount], $ClientVersion[$Sortcount]; + } + else + { + printf CSV "%s,%s,%s\n", $SortedClient, $ClientOS[$Sortcount], + $ClientVersion[$Sortcount]; + } + $LineCount++; + $Sortcount++; + last; + } + $Sortcount++; + } +} +close(QRY); + +if ( $#ARGV == 1 ) +{ + close(CSV); +} + +# +# +############### S P A W A R S H A R E D S E R V I C E S ############ +########################################################################## +# Sub Routines # +########################################################################## +# +# + +sub page_header +{ + $PageCount++; + if ( $PageCount == 1 ) + { + printf + " NetWorker Windows Clinet Audit %s (WinCliAudit.pl)\n", + $Server; + } + else + { + printf + " NetWorker Windows Clinet Audit %s (WinCliAudit.pl)\n", + $Server; + } + printf +" Report Date: %s Page %2d\n", + $RPTDATE, $PageCount; + printf " Report Time: %s\n\n", $RPTTIME; + printf "%23s %35s %s\n", "Client Name", "Client OS", " Networker Version"; + printf "%23s %35s %s\n\n", "===========", "=========", + " ================="; + $LineCount = 8; + return (1); +} + +# +# +############### S P A W A R S H A R E D S E R V I C E S ############ +########################################################################## +# House Keeping # +########################################################################## +# +# + +unlink($WCAQRYNAME); diff --git a/check_backup_clients_old.pl b/check_backup_clients_old.pl new file mode 100644 index 0000000..f290c9d --- /dev/null +++ b/check_backup_clients_old.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl + +print "Building list of servers\n"; +@actual_servers=`/home/preed/list_servers.pl`; +foreach $server (@actual_servers) { + chop $server; + # print "$server\n"; + $check{$server} = 0; +} + +print "Building list of servers backed up\n"; +(@backup_clients)=`/home/preed/list_backup_clients`; +foreach $server (@backup_clients) { + chop $server; + # print "$server\n"; + $check{$server} = 1; +} + +foreach $server (sort(keys %check)) { + # print "$server, $check{$server}\n"; + if ($check{$server} == 0) {print "\tServer $server not being backed up\n"}; +} diff --git a/check_client_groups.pl b/check_client_groups.pl new file mode 100644 index 0000000..be4f663 --- /dev/null +++ b/check_client_groups.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl -w verage Assessment +unshift (@INC,"/home/scriptid/scripts/BACKUPS/SUBROUTINES"); +require handle_nsradmin_line_continuations; +$networker = `/usr/bin/hostname`; +chomp $networker; +# Determine the name, group +my $nsrpass = ". type:NSR client'\n'show name\\;group\\;action'\n'print"; +(@return) = handle_nsradmin_line_continuations($networker,$nsrpass); +print "After nsradmin on $networker\n"; +# Client name is mixed case so lower case the names +print "Determing regular/VADP, Prod/Non Prod, Scheduled/Not scheduled on $networker\n"; +foreach $val (@return) { + chomp $val; + $val =~ s/\;//; + next if $val =~ /^\s*$/; + if ($val =~ /name:/) { + $val =~ s/\s*name: //; + $name = lc($val); + } elsif ($val =~ /group/) { + $val =~ s/\s*group: //; + if (defined $group{$name}) { + print "Client: $name: Client defined multiple times $group{$name}, current groups:$val\n"; + } else { + $group{$name} = $val; + undef %checkers; + (@chkgrp) = split (/,/,$val); + foreach $ggg (@chkgrp) { + if (defined $checkers{$ggg}) { + print "Group already defined for $ggg\n"; + } else { + $checkers{$ggg} = 1; + } + } + } + } +} diff --git a/check_filesystem_size.pl b/check_filesystem_size.pl new file mode 100644 index 0000000..df06461 --- /dev/null +++ b/check_filesystem_size.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl -w +for $j ('dsk5') { + (@files) = `/usr/bin/find /AFTD/$j -type f -exec /usr/bin/ls -1 {} \\; `; + $size_aftd = 0; + foreach $file (@files) { + + ($temp) = `/usr/bin/du -s $file`; + chomp $temp; + my ($kb,$fff) = split(/\s+/,$temp); + $fff =~ s:/AFTD/dsk5/::; + my ($top,$bot,$ff) =($fff=~/(\d\d)\/(\d\d)\/(.*$)/); + print "$top,$bot,$ff\n"; + $size = $kb*512/1000/1000/1000; + $topsize{$top} += $size; + $size_aftd += $size; + } + print "Size = $size\n"; +} +print "Size = $size_aftd GB\n"; + +foreach $val (sort keys %topsize) { + print "Top Directory $val size = $topsize{$val}\n"; +} + + diff --git a/check_for_program_backups.pl b/check_for_program_backups.pl new file mode 100644 index 0000000..33a17f5 --- /dev/null +++ b/check_for_program_backups.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl -w +# +# This program is used to validate that program servers have been backed up during a certain time period +# It will use the start time of the backupscd .. +# +print "Enter the name of the program to check: "; +$program = ; +chomp $program; +$program = lc $program; +# Need to generate a list of servers to search for pattern matches +# Generate for the last month +print "Query for list of backup clients\n"; +(@return) = `/usr/sbin/mminfo -avot -r 'client' -q 'savetime>last month' | /usr/bin/sort | /usr/bin/uniq`; +print "Return from Query for list of backup clients\n\n\n"; +foreach $val (@return) { + chomp $val; + $val = lc $val; + $sindex = 0; + $eindex = 10; + if ($val =~ /$program/) { + $exit = 0; + #print "Begin query for client $val\n"; + (@days) = `/usr/sbin/mminfo -avot -r 'savetime(8)' -q 'client=$val,savetime>05/01/2016,savetime<06/01/2016' | /usr/bin/sort | /usr/bin/uniq`; + print "Server: $val\n"; + TOP: + #print "Eindex=$eindex, Day=$#days\n"; + if ($eindex > $#days) { + $eindex = $#days; + $exit = 1; + } + #print "Sindex=$sindex, Eindex=$eindex\n"; + print "\t"; + for ($i=$sindex;$i<$eindex;$i++) { + chomp $days[$i]; + #print "$i $days[$i], "; + print "$days[$i], "; + } + print "\n"; + + if ($exit==1) { + print "\n"; + next; + } + $sindex = $eindex; + $eindex += 10; + goto TOP; + } +} + diff --git a/check_index_backups.pl b/check_index_backups.pl new file mode 100644 index 0000000..6af541b --- /dev/null +++ b/check_index_backups.pl @@ -0,0 +1,91 @@ +#!/usr/bin/perl -w +# This is used to determine if file system index backups have been created +# The intent is to not only make the filesystems contiguous but also have all client's filesystems contiguous +# Peter Reed (Aventure) +# 07 13, 2017 +# 1.1.0 +# +# Assumptions: +# 1. The real problems are that Cloning and staging write out data +# to secondary media by processing savesets (file systems on +# a client). The challenge is to eliminate contention for a +# specific tape when multiple cloning streams are running +# concurrently. What happens is that cloning stream 1 is +# processing saveset 1234 on tape 456. Cloning stream 2 +# is processing saveset 8910 on tape 1112 but part of saveset +# 8910 is on tape 456 which is still being used by stream 1. +# Stream 2 has to wait for stream 1 to finish. +# +# This is not problem for AFTD devices +# +# 2. For performance reasons, it is better to have virtual tapes being +# read from both jukeboxes. (This coulld have one stream finish early). +# 3. Virtual tapes should be sequecnced oldest to newest with +# the first stream processing the first '# of tapes/number of streams' +# tapes. Consecutive streams read the next '# of tapes/number of streams' +# tapes. The hope is that this will minimize contension for tapes +# 4. Don't know optimal streams for load on AFTD or +# 5. The program backs up all savesets not already written to tape + +$number_of_streams=3; + +# week_day -> $wday begins with Sunday (0) till Saturday (6) +use Time::Local; + +# Get the current time +$seconds_from_1970 = time; +# Determine real world units +($sec,$min,$hour,$mon,$yr,$yday) = (localtime($seconds_from_1970))[0,1,2,4,5,7]; +++$mon; +$yr = $yr+1900; +#$finish="\'$mon/$mday/$yr $hour:$min:$sec\'"; + +# Open the log file +$datestamp = "$yr$yday$hour$min$sec"; +$logfile="/home/scriptid/scripts/BACKUPS/CLONING/clone_log_$datestamp"; +open (LOG,">$logfile") or die "Could not open logfile $logfile\n"; + + +print LOG "Begin cloning $hour:$min:$sec Year:$yr Julian Date:$yday\n"; +# Check to see is cloning is already running +#if (`/usr/bin/pgrep -f "AFTD"`) { +# print LOG "Cloning already running\n"; +# exit; +#} + +# Determine the tapes that were used for the weekend full backups + print "Level"; +(@VOLRETENT) = `/usr/sbin/mminfo -o cn -av -xc, -r 'volume,client,name,ssid(53),savetime(20)' -q 'copies=1,pool=AFTD_POOL,savetime>10 days ago' 2>&1`; +(@VOLRETENT2) = `/usr/sbin/mminfo -o cn -av -xc, -r 'volume,client,name,ssid(53),savetime(20)' -q 'copies=1,pool=AFTD2_POOL,savetime>10 days ago' 2>&1`; +push (@VOLRETENT,@VOLRETENT2); +open (CLONE,">/home/scriptid/scripts/BACKUPS/CLONING/clone_list_$datestamp") or die "Could not open clone_list file\n"; +foreach $val (@VOLRETENT) { + if ($val =~ "[Vv]olume") { + next; + } elsif ($val =~ /expired/) { + next; + } elsif ($val =~ /no matches found for the query/) { + next; + } + chop $val; + my ($volume,$client,$filesystem,$ssid,$savetime) = split(/,/,$val); + if ( defined $client_ssids{$client} ) { + $client_ssids{$client} = "$client_ssids{$client}\:$ssid"; + } else { + $client_ssids{$client} = $ssid; + } +} +foreach $client (sort keys %client_ssids) { + print CLONE "$client:$client_ssids{$client}\n"; +} +$i=0; +while ($i<$number_of_streams) { + ++$i; + $clone_name="CLONE" . $i; + close $clone_name; + print "Starting clone stream $i\n"; + print LOG "/n/nBefore entering process $datestamp $i\n"; + my $ret = system("/home/scriptid/scripts/BACKUPS/process_client_AFTD_clone.pl $datestamp $i &"); + sleep 5; +} +close LOG; diff --git a/check_networker_authentication_for_clients.pl b/check_networker_authentication_for_clients.pl new file mode 100644 index 0000000..d026972 --- /dev/null +++ b/check_networker_authentication_for_clients.pl @@ -0,0 +1,210 @@ +#!/usr/bin/perl -w +# This script is used to look for bad servers files on clients +# type: NSR peer information; +# administrator: gbrandt@*, "isroot,host=sscprodeng", +# "isroot,host=sscprodeng-bk2", +# "isroot,host=sscprodeng-bk2.sscnola.oob", +# "isroot,host=sscprodeng-mn", +# "isroot,host=sscprodeng-mn.sscnola.oob", +# "isroot,host=sscprodeng.sscnola.oob", +# "isroot,host=sscprodeng2", +# "isroot,host=sscprodeng2-bk2", +# "isroot,host=sscprodeng2-bk2.sscnola.oob", +# "isroot,host=sscprodeng2-mn", +# "isroot,host=sscprodeng2-mn.sscnola.oob", +# "isroot,host=sscprodeng2.sscnola.oob", preed@*, +# "user=root,host=localhost", +# "user=root,host=sscprodeng.sscnola.oob"; +# name: c27itsmcnlat1w.dc3n.navy.mil; +# peer hostname: c27itsmcnlat1w.dc3n.navy.mil; +#What is Hidden display option turned on +#What is Display options: +#What is Dynamic: Off; +#What is Hidden: On; +#What is Raw I18N: Off; +#What is Resource ID: Off; +#What is Regexp: Off; +unshift (@INC,"/home/scriptid/scripts/BACKUPS/SUBROUTINES"); +require build_output_record; +require handle_nsradmin_line_continuations; +$date = `date '+%Y%M%D_%H%M%S'`; +$date = `/usr/bin/date '+%y%m%d%H%M%S'`; +chomp $date; +$networker = `/usr/bin/hostname`; +chomp $networker; +$filename = "/home/scriptid/scripts/BACKUPS/clients/client_auth\_$date"; +print "Output filename=$filename\n"; +open (FAILMAIL,">$filename") or die "Could not open $filename\n"; +$FAILADDRS="peter.reed.ctr\@navy.mil jeffrey.l.rodriguez.ctr\@navy.mil cody.p.crawford.ctr\@navy.mil blake.arcement.ctr\@navy.mil"; +print FAILMAIL "/usr/bin/mailx -s 'Client Auth Data $date on $networker' $FAILADDRS <