Skip to content
Snippets Groups Projects
Commit cdb0c8f5 authored by Chris Nehren's avatar Chris Nehren
Browse files

Add an optional cache argument to the WatchOutput command, and test this

value to determine whether to use cache_command or run_command.
parent f867935e
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ Core::WatchOutout - watch a command's output, reporting it
=head1 SYNOPSIS
Core::WatchOutput {
ls: command => "/bin/ls"
ls: command => "/bin/ls", cache => 3600
}
=head1 DESCRIPTION
......@@ -32,6 +32,11 @@ This check will run a given command and return the output as the
This is a string of the command name and any arguments.
=item cache
The duration, in seconds, to cache the output of the command. If this
value is missing, there is no caching.
=back
=head1 METRICS
......@@ -62,8 +67,14 @@ sub handler {
my $self = shift;
my $config = $self->{config};
my $command = $config->{command};
my $output = run_command($command);
my $cache = exists $config->{cache} ? $config->{cache} : 0;
my $output;
if($cache) {
$output = cache_command($command, $cache);
} else {
my $output = run_command($command);
}
chomp $output;
my $status = $? >> 8;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment