Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c67c77b
commit 26169f7
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class CheckTimestamp < Scout::Plugin | ||
def build_report | ||
begin | ||
threshold = option(:threshold).to_f | ||
path = option(:path) | ||
timestamp = File.new(path).mtime | ||
current_time = Time.now | ||
difference = (current_time - timestamp) / 60 | ||
output = "Path: #{path}, Threshold: #{threshold}, Timestamp: #{timestamp}, Current Time: #{current_time}, Difference: #{difference}" | ||
report(:output => output) | ||
if difference > threshold | ||
alert(:subject => "File #{path} was older than #{threshold} minutes", :body => output) | ||
end | ||
return difference | ||
rescue Exception => e | ||
error(:subject => 'Error running Check Timestamp plugin', :body => e) | ||
return -1 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
options: | ||
path: | ||
name: path | ||
notes: path to the file which will have its timestamp checked | ||
default: /fully/qualified/path/to/your/file | ||
threshold: | ||
name: threshold | ||
notes: threshold in minutes for the timestamp. If the timestamp of the file is older than this threshold, an error will be returned. | ||
default: 360 |