diff --git a/lib/Core/WatchOutput.pm b/lib/Core/WatchOutput.pm index dd5900263551a6cea76cc3942e55387d8307922c..d8f099d0e541071af65c3cd100375a7b8da8c217 100644 --- a/lib/Core/WatchOutput.pm +++ b/lib/Core/WatchOutput.pm @@ -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;