Consolidated Bootstrap report for NetWorker
- Platform : Linux and UNIX
- Application : DELL EMC NetWorker 8.2/9.1
Input
The input to this script is being provided via an external file
backup_server_list.txt
. Make sure keep the file at the same location as the script and
in case you are using this in the cron tab then edit the variable
in the script to the complete path to this file to avoid errors
during the execution of the script.
Along with the external file you might also want to assign appropriate values to the below listed variables in the script.
Variable | Value description |
---|---|
$server_details_file_name |
Complete path to the backup_server_list.txt
file on the local system.
|
$email_from |
Sender's email address. |
$email_to |
Recipient's email address. |
$email_subject |
Subject for the email that would contain the consolidated report. |
Output from the script on the console
The output of the script migh be required to check the errors during the run of the script. This can be usually redirected to a log file that gets over written wverytime the script runs to avoid the log taking a lot of disk space.
nwserver:/home/rovin $
/home/rovin/scripts/bootstrap_report/bootstrap_report.pl
------------------ Script Initiated ------------------
Collecting Bootstrap information for nwserver1.
Collecting
Bootstrap information for nwserver2.
Collecting Bootstrap
information for nwserver3.
Collecting Bootstrap information
for nwserver4.
Collecting Bootstrap information for
nwserver5.
Collecting Bootstrap information for nwserver6.
Collecting Bootstrap information for nwserver7.
Collecting
Bootstrap information for nwserver8.
Collecting Bootstrap
information for nwserver9.
Collecting Bootstrap information
for nwserver10.
87988:mminfo: Unable to connect to media
database server on host nwserver11: Unable to connect to nsrexecd
on host nwserver1 for RAP credentials: Unknown host
Sample email report
bootstrap_report.pl
#! /usr/bin/perl -w
# Details regarding this script can be found on http://www.crazyrov.com/prod/dp/dp_script_cbr.php
my $today_date = `date +'%d-%m-%Y'`;
chomp $today_date;
my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime();
my $server_details_file_name = "backup_server_list.txt";
my $email_holder = "/tmp/bootstrap_email_holder.txt";
my $email_from="sender\@crazyrov.com";
my $email_to="stake_holders\@crazyrov.com";
my $email_subject="CUSTOMER_NAME Bootstrap Report - $today_date";
my @server_lists;
print "------------------ Script Initiated ------------------\n";
@server_lists = `cat $server_details_file_name`;
email_header($email_holder, $email_subject, $email_from, $email_to);
open(my $fh, '>>', $email_holder) or die "Could not open file '$email_holder' $!";
for my $server (@server_lists)
{
chomp($server);
print "Collecting Bootstrap information for $server. \n";
print $fh "<tr>
<td style=\"background-color: #CCCCCC; color:#003366 ;padding: 3px\">".uc($server)."</t>";
print $fh ` /usr/sbin/mminfo -s $server -B -xc, | grep -v record | tail -1 | awk -F',' '{ print "<td style=\\\"background-color: #CCCCCC; color:#003366 ;padding: 3px\\\">",\$1, "</td><td style=\\\"background-color: #CCCCCC; color:#003366 ;padding: 3px\\\">", \$2, "</td><td style=\\\"background-color: #CCCCCC; color:#003366 ;padding: 3px\\\">",\$5, "</td><td style=\\\"background-color: #CCCCCC; color:#003366 ;padding: 3px\\\">",\$7,"</td><td style=\\\"background-color: #CCCCCC; color:#003366 ;padding: 3px\\\">",\$9,"</td>" }'`;
print $fh "</tr>";
}
close($fh);
email_footer($email_holder);
print "\n------------------ Sending email now ------------------\n";
system("cat $email_holder | /usr/sbin/sendmail -t");
print "------------------ Script Completed ------------------\n";
# Subroutines
sub email_header{
my $holder = $_[0];
open(my $fh, '>', $holder) or die "Could not open file '$holder' $!";
print $fh 'From: $_[2]
To: $_[3]
Subject: $_[1]
Content-Type: text/html
MIME-Version: 1.0
<!doctype html>
<html>
<head>
<meta charset=\"utf-8\">
<title>CUSTOMER_NAME Bootstrap Report by Rovin D\'Souza</title>
</head>
<body style=\"font-family:Segoe, \'Segoe UI\', \'DejaVu Sans\', \'Trebuchet MS\', Verdana, sans-serif \">
<div id=\"main_heading\" align=\"center\" style=\"margin-top: 20px;margin-bottom:20px;font-size:larger;background:#00628B;height:60px;\">
<b><p><span style=\"color:#FFFFFF;height: 100%\">".$email_subject."</span></p></b>
</div>
<div class=\"content\" align=\"center\" style=\"margin-left:2%;margin-right:2%\">
<table style=\"font-family:Segoe, \'Segoe UI\', \'DejaVu Sans\', \'Trebuchet MS\ ', Verdana, sans-serif \"width=\"100%\" border=\"0\">
<tbody style=\"height:20px\">
<tr>
<td> </td>
</tr>
</tbody>
</table>
<table width=\"80%\" align=\"center\" style=\"background-color: background ;\">
<tr>
<th style=\"padding: 5px; background-color: #003366; color: #CCCCCC\">Server</th>
<th style=\"padding: 5px; background-color: #003366; color: #CCCCCC\">Date</th>
<th style=\"padding: 5px; background-color: #003366; color: #CCCCCC\">SSID</th>
<th style=\"padding: 5px; background-color: #003366; color: #CCCCCC\">Volume</th>
<th style=\"padding: 5px; background-color: #003366; color: #CCCCCC\">Volume Location</th>
<th style=\"padding: 5px; background-color: #003366; color: #CCCCCC\">Volume access information</th>
</tr>';
close ($fh);
}
sub email_footer{
my $holder = $_[0];
open(my $fh, '>>', $holder) or die "Could not open file '$holder' $!";
print $fh '
</table>
</body>
</html> ';
close ($fh);
}
Support/Contact
Email your feedback to support@crazyrov.com.