From commits-return-317-apmail-whimsical-commits-archive=whimsical.apache.org@whimsical.apache.org Mon Jan 18 19:20:36 2016 Return-Path: X-Original-To: apmail-whimsical-commits-archive@minotaur.apache.org Delivered-To: apmail-whimsical-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 70EA418647 for ; Mon, 18 Jan 2016 19:20:36 +0000 (UTC) Received: (qmail 39355 invoked by uid 500); 18 Jan 2016 19:20:36 -0000 Delivered-To: apmail-whimsical-commits-archive@whimsical.apache.org Received: (qmail 39334 invoked by uid 500); 18 Jan 2016 19:20:36 -0000 Mailing-List: contact commits-help@whimsical.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@whimsical.apache.org Delivered-To: mailing list commits@whimsical.apache.org Received: (qmail 39325 invoked by uid 99); 18 Jan 2016 19:20:36 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jan 2016 19:20:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id DB33EC0ECE for ; Mon, 18 Jan 2016 19:20:35 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.247 X-Spam-Level: * X-Spam-Status: No, score=1.247 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.554, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id C18EgqQnAqk2 for ; Mon, 18 Jan 2016 19:20:24 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 6DFE521265 for ; Mon, 18 Jan 2016 19:20:24 +0000 (UTC) Received: from matt.apache.org (unknown [207.244.88.130]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id E32DEE04C7 for ; Mon, 18 Jan 2016 19:20:23 +0000 (UTC) Received: by matt.apache.org (ASF Mail Server at matt.apache.org, from userid 33) id C431C7DE8; Mon, 18 Jan 2016 19:20:22 +0000 (UTC) From: Sam Ruby Reply-To: commits@whimsical.apache.org To: commits@whimsical.apache.org Subject: [whimsy.git] [2/2] Commit 52094b4: Merge branch 'master' of github.com:apache/whimsy Message-Id: <20160118192022.C431C7DE8@matt.apache.org> Date: Mon, 18 Jan 2016 19:20:22 +0000 (UTC) Commit 52094b45ce474e23e939bc5bd492ed67d6d4a65b: Merge branch 'master' of github.com:apache/whimsy Branch: refs/heads/master Author: Sam Ruby Committer: Sam Ruby Pusher: rubys ------------------------------------------------------------ www/status/errors.cgi | +++++++++++++++ www/status/index.cgi | + - www/status/monitors/svn.rb | ++++++++ ----- ------------------------------------------------------------ 73 changes: 67 additions, 6 deletions. ------------------------------------------------------------ diff --git a/www/status/errors.cgi b/www/status/errors.cgi new file mode 100755 index 0000000..f98b3f1 --- /dev/null +++ b/www/status/errors.cgi @@ -0,0 +1,58 @@ +#!/usr/bin/ruby + +# +# Fetch and parse the Ping My Box error log +# + +require 'wunderbar' +require 'uri' +require 'yaml' +require 'net/http' +require 'time' + +# fetch status +uri = URI.parse('https://www.pingmybox.com/api.pmb?what=errors&id=470') +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true +request = Net::HTTP::Get.new(uri.request_uri) +response = http.request(request) + +# extract time, pinger, and exception from response +exceptions = YAML.load(response.body).map do |hash| + exception = hash['debug'][/Caught exception: .*?: (.*)/m, 1].strip + [Time.at(hash['time']), hash['pinger'], exception] +end + +# produce table +_html do + _link rel: 'stylesheet', href: 'css/bootstrap.min.css' + _h1 'Error Log' + + _table.table do + _tr_ do + _th 'Time' + _th 'Pinger' + _th 'Status' + _th 'Error' + end + + exceptions.sort.reverse.each do |time, pinger, text| + color = (text.include?('HTTP/1.1 3') ? 'warning' : 'danger') + _tr_ class: color do + _td time.iso8601 + _td align: 'right' do + _a pinger, href: + "https://www.pingmybox.com/pings?location=470&pinger=#{pinger}" + end + _td text[/^HTTP\/1.1 (\d+)/, 1] + _td text.sub(/^HTTP\/1.1 \d+/, '') + end + end + end + + _p do + _a 'raw log', href: uri.to_s + end +end + + diff --git a/www/status/index.cgi b/www/status/index.cgi index d7a5e50..b632d88 100755 --- a/www/status/index.cgi +++ b/www/status/index.cgi @@ -54,7 +54,7 @@ print <<-EOF

This status is monitored by: Ping My - Box. + Box (full log).

diff --git a/www/status/monitors/svn.rb b/www/status/monitors/svn.rb index c39a805..ab07aeb 100644 --- a/www/status/monitors/svn.rb +++ b/www/status/monitors/svn.rb @@ -4,9 +4,9 @@ def Monitor.svn(previous_status) # read cron log - log = File.expand_path('../../www/logs/svn-update') - updates = File.read(log).split("\n/srv/svn/") - updates.shift + log = File.expand_path('../../../logs/svn-update', __FILE__) + data = File.open(log) {|file| file.flock(File::LOCK_EX); file.read} + updates = data.split("\n/srv/svn/")[1..-1] status = {} @@ -30,7 +30,10 @@ def Monitor.svn(previous_status) lines.reject! {|line| line =~ /^[ADU] /} if lines.empty? - if data.length == 1 + if not data + title = "partial response" + level = 'warning' + elsif data.length == 1 title = "1 file updated" else title = "#{data.length} files updated" @@ -42,7 +45,7 @@ def Monitor.svn(previous_status) data = lines.dup end - status[repository] = {level: level, data: data} + status[repository] = {level: level, data: data, href: '../logs/svn-update'} status[repository][:title] = title if title end