This is an automated email from the ASF dual-hosted git repository. rubys pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push: new 74084bf monitor site scan 74084bf is described below commit 74084bf5b58edf1eab4049601a91d44f29c6ca20 Author: Sam Ruby <ru...@intertwingly.net> AuthorDate: Tue Aug 8 20:30:42 2017 -0400 monitor site scan --- www/status/monitors/site_scan.rb | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/www/status/monitors/site_scan.rb b/www/status/monitors/site_scan.rb new file mode 100644 index 0000000..0836b5e --- /dev/null +++ b/www/status/monitors/site_scan.rb @@ -0,0 +1,46 @@ +# +# Monitor status of site-scan +# + +=begin +The code checks the site-scan log file + +Possible status level responses: +Danger - log contains an unexpected content +Warning - log hasn't been updated within a day +Info - log is recent and contains only expected content + +=end + +require 'time' + +def Monitor.site_scan(previous_status) + logfile = File.expand_path('../../www/logs/site-scan') + log = File.read(logfile) + + log.gsub! /\w+ https?:\S+ \w+\n/, '' + + danger_period = 86_400 # one day + + if not log.empty? + { + level: 'danger', + data: log.split("\n"), + href: '../logs/site-scan' + } + elsif Time.now - File.mtime(logfile) > danger_period + { + level: 'warning', + data: "Last updated: #{File.mtime(logfile)}", + href: '../logs/site-scan' + } + else + {mtime: File.mtime(logfile).gmtime.iso8601, level: 'success'} + end +end + +# for debugging purposes +if __FILE__ == $0 + require_relative 'unit_test' + runtest('site_scan') # must agree with method name above +end -- To stop receiving notification emails like this one, please contact ['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].