);
my $next_time = undef;
+my @alerts = ();
# The blocks of output which we might generate.
my @blocks = (
my $percent = sprintf("%.1f",
$vars->{'_total_used'} / $vars->{'_total_total'} * 100);
if ($percent >= $disk_space_warn) {
+ push @alerts, "DISK SPACE";
return "$warning$percent\%$normal";
} else {
return "$safe$percent\%$normal";
my $percent = sprintf("%.1f",
$vars->{'drive_total_used'} / $vars->{'drive_total_total'} * 100);
if ($percent >= $disk_space_warn) {
+ push @alerts, "DISK SPACE";
return "$warning$percent\%$normal";
} else {
return "$safe$percent\%$normal";
# A couple of global variables
my ($xml, $xml_version, $myth);
-my $schedule_conflicts_present = 0;
my $title = "MythTV status for $host";
my $output = "$title\n";
if (scalar(@email) == 0) {
print "\n$output";
} else {
- if (! ($email_only_on_conflict && ! $schedule_conflicts_present)) {
+ if (! ($email_only_on_conflict && scalar(@alerts) > 0)) {
+ my $suffix = undef;
+ if (@alerts == 1) {
+ $suffix = $alerts[0];
+ } elsif (@alerts > 1) {
+ $suffix = "MULTIPLE WARNINGS";
+ }
+
my $mail = MIME::Entity->build(
To => \@email,
- Subject => $title . ($schedule_conflicts_present ? ' - CONFLICTS' : ''),
+ Subject => $title . (defined $suffix ? " - $suffix" : ''),
Data => $output
);
}
}
- $schedule_conflicts_present = scalar(@lines);
+ if (scalar(@lines) == 1) {
+ push @alerts, "CONFLICT";
+ } elsif (scalar(@lines) > 1) {
+ push @alerts, "CONFLICTS";
+ }
return join("\n", @lines);
}