+
+###########################################################################
+# Generate sysadmin warning message
+###########################################################################
+my $adminMesg = "";
+
+if ( @AdminBadHosts ) {
+ my $badHosts = join("\n - ", sort(@AdminBadHosts));
+ $adminMesg .= <<EOF;
+The following hosts had an error that is probably caused by a
+misconfiguration. Please fix these hosts:
+ - $badHosts
+
+EOF
+}
+
+#
+# Report if we skipped backups because the disk was too full
+#
+if ( $Info{DUDailySkipHostCntPrev} > 0 ) {
+ my $n = $Info{DUDailySkipHostCntPrev};
+ my $m = $Conf{DfMaxUsagePct};
+ $adminMesg .= <<EOF;
+Yesterday $n hosts were skipped because the file system containing
+$TopDir was too full. The threshold in the
+configuration file is $m%, while yesterday the file system was
+up to $Info{DUDailyMaxPrev}% full. Please find more space on the file system,
+or reduce the number of full or incremental backups that we keep.
+
+EOF
+}
+
+#
+# Check for bogus directories (probably PCs that are no longer
+# on the backup list)
+#
+my $d = DirHandle->new("$TopDir/pc") or die("Can't read $TopDir/pc: $!");
+my @oldDirs = ();
+my @files = $d->read;
+$d->close;
+foreach my $host ( @files ) {
+ next if ( $host =~ /^\./ || defined($Status{$host}) );
+ push(@oldDirs, "$TopDir/pc/$host");
+}
+if ( @oldDirs ) {
+ my $oldDirs = join("\n - ", sort(@oldDirs));
+ $adminMesg .= <<EOF;
+The following directories are bogus and are not being used by
+BackupPC. This typically happens when PCs are removed from the
+backup list. If you don't need any old backups from these PCs you
+should remove these directories. If there are machines on this
+list that should be backed up then there is a problem with the
+hosts file:
+ - $oldDirs
+
+EOF
+}
+
+if ( $adminMesg ne "" && $Conf{EMailAdminUserName} ne "" ) {
+ my $headers = $Conf{EMailHeaders};
+ $headers .= "\n" if ( $headers !~ /\n$/ );
+ $adminMesg = <<EOF;
+To: $Conf{EMailAdminUserName}
+Subject: BackupPC administrative attention needed
+$headers
+${adminMesg}Regards,
+PC Backup Genie
+EOF
+ SendMail($adminMesg);
+}
+
+###########################################################################
+# Save email state and exit
+###########################################################################