CRAZYROV STUDIO

perl script Avamar Health-check Dashboard

This script helps you get a consolidated view of multiple Avamar system services. The script can be run from an UNIX or LINUX system with the following listed prerequisites met and it would collect all the information related to the running grids, consolidate and format it to an email. This email is then automatically sent to the intended recipients. Like always if you have any feedback regarding this script you can reach out to us.
This script was developed and tested on
  • Platform : Linux and UNIX
  • Application : DELL EMC Avamar 7.2/7.3/7.4

Prerequisites


There are a few perquisites that you need to meet before using this script.
  • Set up ssh without password for the user that you are going to use to run the master script. Incase you are not aware of the procedure follow the procedure as described here.
  • sendmail is installed and configured on the server running the master script

Input


The input to this script is being provided via an external file grid_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 master script.

Variable Value description
$grid_list Complete path to the gridr_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.

Sample email report

sample_outout_for_consolidated_Avamar_health_check_report

ava_status.pl

    #!/usr/bin/perl -w
#
# Details regarding this script can be found on http://www.crazyrov.com/prod/dp/dp_script_ahcd.php
#


my $today_date = `date +'%d-%m-%Y'`;
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 $grid_list="/home/resebr/scripts/ava_status/grid_list.txt";
my $email_holder = "/tmp/email_avamar_status_holder.txt";
my $email_from="sender\@crazyrov.com";
my $email_to="recipient\@crazyrov.com";
chomp($today_date);
my @fields=(" gsan status"," MCS status"," emt status"," Backup scheduler status"," Maintenance windows scheduler status"," Unattended startup status"," avinstaller status"," ddrmaint-service status");

my $email_subject="CUSTOMER_NAME Avamar status Report - $today_date";


print "------------------ Script Initiated ------------------\n";
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 (`cat $grid_list`)
{
	chomp($server);
    print "Collecting Grid Status information for $server. \n";
    print $fh "<tr>
            <td style=\"background-color: #CCCCCC; color:#003366;padding:5px;border: 1px solid #2556A3;\">$server</td>\n";
			
system "ssh -q admin\@$server dpnctl status > /tmp/output.txt 2>&1";
#@output=`cat /tmp/output.txt | grep dpnctl | awk -F':' '{  if(\$4 == " up" || \$4 == " up." || \$4 == " enabled.") print 1; else print 0;}'`;
@output=`cat /tmp/output.txt | grep dpnctl | awk -F':' '{  print \$3,",",\$4}'`;

	for(my $i=0,$j=0; $i < scalar @fields; $i++) {
	
	my @field_parameters = split(" , ",$output[$j]);
	chomp($field_parameters[1]);
	print "".$field_parameters[0]." : ".$field_parameters[1]."\n";

	if( $field_parameters[0] eq "$fields[$i]" &&  ($field_parameters[1]  eq " up" || $field_parameters[1] eq " up." || $field_parameters[1] eq " enabled."))
	{
		print $fh "<td style=\"padding: 5px; background-color: #00FF00; border: 1px solid #4CC116;\"></td>\n";
		$j++;			

	} elsif($field_parameters[0] eq "$fields[$i]"){
		print $fh "<td style=\"padding: 5px; background-color: #FF0000; border: 1px solid #AD1717;\"></td>\n";
		$j++;
	} else {
		print $fh "<td style=\"padding: 5px; background-color: #0000FF; ;border: 1px solid #5C78E1;\">NA</td>\n";
	}
}
        print $fh "</tr>\n";

}

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>NIKE Avamar Status 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:#00C2EE;height:100px;\">
<b><p><span style=\padding-top:40px;display:block;color:#000000;height:100px;\">".$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  border=\"0\" width=\"80%\" align=\"center\" style=\"background-color: background ;\">
        <tr >
            <th style=\"padding: 5px; background-color: #003366; color: #CCCCCC;border: 1px solid #9AC1DF;\">Utility Grid</th>
            <th style=\"padding: 5px; background-color: #003366; color: #CCCCCC;border: 1px solid #9AC1DF;\">GSAN</th>
            <th style=\"padding: 5px; background-color: #003366; color: #CCCCCC;border: 1px solid #9AC1DF;\">MCS</th>
            <th style=\"padding: 5px; background-color: #003366; color: #CCCCCC;border: 1px solid #9AC1DF;\">EMT</th>
            <th style=\"padding: 5px; background-color: #003366; color: #CCCCCC;border: 1px solid #9AC1DF;\">Backup Scheduler</th>
            <th style=\"padding: 5px; background-color: #003366; color: #CCCCCC;border: 1px solid #9AC1DF;\">Maintenance Scheduler </th>
			<th style=\"padding: 5px; background-color: #003366; color: #CCCCCC;border: 1px solid #9AC1DF;\">Unattended startup</th>
            <th style=\"padding: 5px; background-color: #003366; color: #CCCCCC;border: 1px solid #9AC1DF;\">AV installed</th>
            <th style=\"padding: 5px; background-color: #003366; color: #CCCCCC;border: 1px solid #9AC1DF;\">ddrmaint-service</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.