$c->{'host'} ||= "localhost";
$c->{'port'} ||= "6544";
$c->{'colour'} ||= 0;
+$c->{'highlight'} ||= -1;
$c->{'episode'} ||= 0;
$c->{'description'} ||= 0;
$c->{'encoder_details'} ||= 0;
'e|episode!' => \$c->{'episode'},
'encoder-details!' => \$c->{'encoder_details'},
'h|host=s' => \$c->{'host'},
+ 'highlight!' => \$c->{'highlight'},
'p|port=i' => \$c->{'port'},
'v|version' => \&print_version,
'email=s@' => \@{ $c->{'email'} },
# Get the email address into a format we can use.
@{ $c->{'email'} } = split(',', join(',', @{ $c->{'email'} }));
-# Default to not showing some blocks if we're sending email, but let the
-# user override us.
+# Default settings for emails but let the user override us.
if (scalar(@{ $c->{'email'} }) > 0) {
+ # Disable these blocks
for my $block ('Encoders', 'Recording Now', 'Next Recording In') {
if (! defined $c->{'display'}{$block}) {
$c->{'display'}{$block} = 0;
}
}
+
+ # Enable highlight
+ if ($c->{'highlight'} == -1) {
+ $c->{'highlight'} = 1;
+ }
}
-# Possibly use some colour, but not in emails.
+# Possibly use some colour or highlighting, but not no colour in emails.
my $safe = '';
-my $warning = '';
-my $normal = '';
+my $warn = '';
+my $warn_to_normal = '';
+my $safe_to_normal = '';
if ($c->{'colour'} && scalar(@{ $c->{'email'} }) == 0) {
- $safe = "\033[0;32m";
- $warning = "\033[1;31m";
- $normal = "\033[0m";
+ $safe = "\033[0;32m";
+ $warn = "\033[1;31m";
+ $safe_to_normal = "\033[0m";
+ $warn_to_normal = "\033[0m";
+}
+
+if ($c->{'highlight'} > 0) {
+ $warn .= '*';
+ $warn_to_normal = "*$warn_to_normal";
}
# Is a warning present?
'attrs' => [ qw/hostname id state connected/ ],
'template' => "__hostname__ (__id__) - __state____connected__",
'rewrite' => {
- '/connected/' => { '1' => '', '0' => "${warning}(Disconnected)${normal}" },
+ '/connected/' => { '1' => '', '0' => "${warn}(Disconnected)${warn_to_normal}" },
'/state/' => {
- '^0$' => "${safe}Idle${normal}",
- '^1$' => "${warning}Watching LiveTV${normal}",
- '^2$' => "${warning}Watching Pre-recorded${normal}",
- '^3$' => "${warning}Watching Recording${normal}",
- '^4$' => "${warning}Recording${normal}",
+ '^0$' => "${safe}Idle${safe_to_normal}",
+ '^1$' => "${warn}Watching LiveTV${warn_to_normal}",
+ '^2$' => "${warn}Watching Pre-recorded${warn_to_normal}",
+ '^3$' => "${warn}Watching Recording${warn_to_normal}",
+ '^4$' => "${warn}Recording${warn_to_normal}",
},
},
'filter' => {
'attrs' => [ qw/hostname id state connected/ ],
'template' => "__hostname__ (__id__) - __state____connected__",
'rewrite' => {
- '/connected/' => { '1' => '', '0' => "${warning}(Disconnected)${normal}" },
+ '/connected/' => { '1' => '', '0' => "${warn}(Disconnected)${warn_to_normal}" },
'/state/' => {
- '^-1$' => "${warning}Error${normal}",
- '^0$' => "${safe}Idle${normal}",
- '^1$' => "${warning}Watching LiveTV${normal}",
- '^2$' => "${warning}Watching Pre-recorded${normal}",
- '^3$' => "${warning}Watching DVD${normal}",
- '^4$' => "${warning}Watching Video${normal}",
- '^5$' => "${warning}Watching Recording${normal}",
- '^6$' => "${warning}Recording${normal}",
+ '^-1$' => "${warn}Error${warn_to_normal}",
+ '^0$' => "${safe}Idle${safe_to_normal}",
+ '^1$' => "${warn}Watching LiveTV${warn_to_normal}",
+ '^2$' => "${warn}Watching Pre-recorded${warn_to_normal}",
+ '^3$' => "${warn}Watching DVD${warn_to_normal}",
+ '^4$' => "${warn}Watching Video${warn_to_normal}",
+ '^5$' => "${warn}Watching Recording${warn_to_normal}",
+ '^6$' => "${warn}Recording${warn_to_normal}",
},
},
'filter' => {
'attrs' => [ qw/hostname id state devlabel connected/ ],
'template' => "__hostname__ (__id____devtype__) - __state____connected__",
'rewrite' => {
- '/connected/' => { '1' => '', '0' => "${warning}(Disconnected)${normal}" },
+ '/connected/' => { '1' => '', '0' => "${warn}(Disconnected)${warn_to_normal}" },
'/state/' => {
- '^-1$' => "${warning}Error${normal}",
- '^0$' => "${safe}Idle${normal}",
- '^1$' => "${warning}Watching LiveTV${normal}",
- '^2$' => "${warning}Watching Pre-recorded${normal}",
- '^3$' => "${warning}Watching DVD${normal}",
- '^4$' => "${warning}Watching Blu-ray${normal}",
- '^5$' => "${warning}Watching Video${normal}",
- '^6$' => "${warning}Watching Recording${normal}",
- '^7$' => "${warning}Recording${normal}",
+ '^-1$' => "${warn}Error${warn_to_normal}",
+ '^0$' => "${safe}Idle${safe_to_normal}",
+ '^1$' => "${warn}Watching LiveTV${warn_to_normal}",
+ '^2$' => "${warn}Watching Pre-recorded${warn_to_normal}",
+ '^3$' => "${warn}Watching DVD${warn_to_normal}",
+ '^4$' => "${warn}Watching Blu-ray${warn_to_normal}",
+ '^5$' => "${warn}Watching Video${warn_to_normal}",
+ '^6$' => "${warn}Watching Recording${warn_to_normal}",
+ '^7$' => "${warn}Recording${warn_to_normal}",
},
},
'filter' => {
if ($seconds <= $c->{'recording_in_warn'}) {
$warn_present ||= 1;
- $str = "$warning$str$normal";
+ $str = "$warn$str$warn_to_normal";
}
return $str;
'&guideDays' => sub {
if ($_[0] <= $c->{'guide_days_warn'}) {
$warn_present ||= 1;
- return "$warning$_[0]$normal";
+ return "$warn$_[0]$warn_to_normal";
} else {
- return "$safe$_[0]$normal";
+ return "$safe$_[0]$safe_to_normal";
}
},
'/guideThru/' => { 'T\d+:\d+:\d+' => ' ' },
'&guideThru' => sub {
if ($_[1]->{'guideDays'} <= $c->{'guide_days_warn'}) {
$warn_present ||= 1;
- return "$warning$_[0]$normal";
+ return "$warn$_[0]$warn_to_normal";
} else {
- return "$safe$_[0]$normal";
+ return "$safe$_[0]$safe_to_normal";
}
},
},
'format' => 'one line',
'type' => 'xpath',
'xpath' => '//Status/MachineInfo/Guide[@status=""]',
- 'template' => "${warning}No guide data!${normal}",
+ 'template' => "${warn}No guide data!${warn_to_normal}",
},
);
if ($percent >= $c->{'disk_space_warn'}) {
$exit_value ||= 1;
push @alerts, "DISK SPACE";
- return "$warning$percent\%$normal";
+ return "$warn$percent\%$warn_to_normal";
} else {
- return "$safe$percent\%$normal";
+ return "$safe$percent\%$safe_to_normal";
}
}
To turn the additional blocks on you can use B<--encoders>, B<--recording-now>
and/or B<--next-recording>.
+By default highlight is turned on, to disable it use B<--nohighlight>.
+
=item B<--email-only-on-alert>
Only send an email out (if --email is present) if there is an alert
The host to check, defaults to localhost.
+=item B<--highlight>
+
+Surround any items that are considered a warning with asterisks. This helps
+to highlight an issue if colour mode is disabled.
+
=item B<--nostatus>, B<--noencoders>, B<--norecording-now>, B<--noscheduled-recordings>, B<--noschedule-conflicts>, B<--nonext-recording>, B<--nototal-disk-space>, B<--nodisk-space>, B<--noguide-data>, B<--noauto-expire>
Suppress displaying blocks of the output if they would normally be displayed.