Acme Corporation Network Infrastructure Monthly Uptime Report
\n
Date : $sdate
EOF
print SENDMAIL "Report for the Month of $months[$month]
\n";
print SENDMAIL "
\n";
print SENDMAIL "There were a total of $devicecount devices monitored during this month.
\n";
# print SENDMAIL "The total number of seconds in this month was $tutfm. ";
# print SENDMAIL "Multiple that by the total number of devices = ", $tutfm*$devicecount, "
\n";
print SENDMAIL "
\n";
# print SENDMAIL "We were down for a total of $totaldowntime seconds (,",
# &calc_down_time($totaldowntime), " DD:HH:MM:SS)
\n";
print SENDMAIL "The network uptime for this month was ";
printf SENDMAIL " %0.3f%%\n", ((($tutfm * $devicecount) - $totaldowntime)
/ ($tutfm * $devicecount)) * 100;
print SENDMAIL "\n";
print SENDMAIL "
\n"; print SENDMAIL "
\n";
print SENDMAIL "Here is the itemized breakdown for each device;
\n";
print SENDMAIL "
Device Hostname or IP Address | "; print SENDMAIL "# Events | "; print SENDMAIL "Time Down DD:HH:MM:SS | ";
print SENDMAIL "% Uptime | "; print SENDMAIL "
$fontopen$idx | \n"; print SENDMAIL "$fontopen$count{$idx} | \n"; print SENDMAIL "$fontopen$dTime | \n"; print SENDMAIL "$fontopen"; printf SENDMAIL " %0.3f%%\n", (($tutfm - $down{$idx}) / $tutfm ) * 100; print SENDMAIL " | \n"; print SENDMAIL "
\n
\n
EOF
close(SENDMAIL) || die;
return 1;
} #end sub output_report
########################################################################
# Subroutine byKeys
#
# Purpose: sort the DNS domain names from the Hash Array for output
########################################################################
sub byKeys {
# Declare Local Variables
my ($a_host, $a_domain1, $a_domain2, $a_domain3, $b_host, $b_domain1, $b_domain2, $b_domain3);
# Split the FQDN into seperate variables
($a_host, $a_domain1, $a_domain2, $a_domain3) = split (/\./, $a);
($b_host, $b_domain1, $b_domain2, $b_domain3) = split (/\./, $b);
# If DEBUG output the seperate variables for troubleshooting
print "DEBUG: $a_host, $a_domain1, $a_domain2, $a_domain3\n" if (DEBUG);
print "DEBUG: $b_host, $b_domain1, $b_domain2, $b_domain3\n" if (DEBUG);
print "DEBUG: a = $a\n" if (DEBUG);
print "DEBUG: b = $b\n" if (DEBUG);
# if (($a_host cmp $b_host) != 0) { $a_host cmp $b_host; }
# elsif (($a_domain1 cmp $b_domain1) != 0) { $a_domain1 cmp $b_domain1; }
# elsif (($a_domain2 cmp $b_domain2) != 0) { $a_domain2 cmp $b_domain2; }
# elsif (($a_domain3 cmp $b_domain3) != 0) { $a_domain3 cmp $b_domain3; }
# If the root domain equals each other continue else evaluate
if (($a_domain3 cmp $b_domain3) != 0) { $a_domain3 cmp $b_domain3; }
# If the subdomain *.org equals each other continue else evaluate
elsif (($a_domain2 cmp $b_domain2) != 0) { $a_domain2 cmp $b_domain2; }
# if the subdomain *.*.org equals each other continue else evaluate
elsif (($a_domain1 cmp $b_domain1) != 0) { $a_domain1 cmp $b_domain1; }
# If the doamins equals each other evaluate the hostname
elsif (($a_host cmp $b_host) != 0) { $a_host cmp $b_host; }
} #end sub bykeys