finch 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  finch is a barebone monitoring dashboard.
4
4
 
5
+ ![finch](https://raw.github.com/chatgris/finch/master/example/finch.jpg)
6
+
5
7
  ## Installation
6
8
 
7
9
  Ruby 1.9.2 is required.
@@ -26,9 +28,15 @@ Configure a `config.ru` file:
26
28
  require "finch"
27
29
 
28
30
  Finch.declare do |declarator|
29
- declarator.ping name: "Redis", host: "localhost", port: 6379, id: "redis"
30
- declarator.ping name: "Mongo", host: "localhost", port: 27017, id: "mongo"
31
- declarator.ping name: "ElasticSearch", host: "localhost", port: 9200, id: "es"
31
+ declarator.ping "Admin", host: "localhost", port: 3000, group: "Apps"
32
+ declarator.ping "Front", host: "localhost", port: 3000, group: "Apps"
33
+ declarator.ping "Public Api", host: "localhost", port: 3200, group: "Api"
34
+ declarator.ping "Private Api", host: "localhost", port: 3300, group: "Api"
35
+ declarator.ping "Redis", host: "localhost", port: 6379, group: "DB"
36
+ declarator.ping "Mongo", host: "localhost", port: 27017, group: "DB"
37
+ declarator.ping "ElasticSearch", host: "localhost", port: 9200, group: "DB"
38
+ declarator.ping "Beanstalkd", host: "localhost", port: 11300, group: "Messaging"
39
+ declarator.ping "Finch", host: "localhost", port: 9292
32
40
  end
33
41
 
34
42
  run Finch::App
data/lib/finch.rb CHANGED
@@ -11,9 +11,10 @@ module Finch
11
11
  state == :ok ? "success" : "error"
12
12
  end
13
13
  end
14
+
14
15
  get "/" do
15
- slim :ping, locals: {pings: settings.declarator_ids.map do |id|
16
- Celluloid::Actor[id]
16
+ slim :ping, locals: {pings: settings.pings.map do |ping|
17
+ Celluloid::Actor[ping]
17
18
  end
18
19
  }
19
20
  end
@@ -21,13 +22,14 @@ module Finch
21
22
 
22
23
  class Pinger
23
24
  include Celluloid
24
- attr_reader :timer, :host, :port
25
+ attr_reader :timer, :host, :port, :group
25
26
  attr_accessor :last_success, :state, :name
26
27
 
27
- def initialize(opts = {})
28
- @name = opts.fetch(:name, "Unkown")
28
+ def initialize(name, opts = {})
29
+ @name = name
29
30
  @host = opts.fetch(:host, "localhost")
30
- @port = opts[:port]
31
+ @group = opts.fetch(:group, "Default")
32
+ @port = opts.fetch(:port, lambda { raise(ArgumentError) })
31
33
  @timer = every(opts.fetch(:frequency, 30)) { ping }
32
34
  ping
33
35
  end
@@ -53,21 +55,21 @@ module Finch
53
55
  end
54
56
 
55
57
  class Declator
56
- attr_reader :ids
58
+ attr_reader :pings
57
59
 
58
60
  def initialize
59
- @ids = []
61
+ @pings = []
60
62
  end
61
63
 
62
- def ping(opts)
63
- ids << id = opts.delete(:id)
64
- Pinger.supervise_as(id, opts)
64
+ def ping(name, opts)
65
+ pings << name
66
+ Pinger.supervise_as(name, name, opts)
65
67
  end
66
68
  end
67
69
 
68
70
  def declare
69
71
  yield declarator = Declator.new
70
- App.set :declarator_ids, declarator.ids
72
+ App.set :pings, declarator.pings
71
73
  end
72
74
 
73
75
  module_function :declare
data/lib/finch/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Finch
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
data/lib/views/ping.slim CHANGED
@@ -2,8 +2,9 @@ doctype
2
2
  html
3
3
  head
4
4
  meta charset="utf-8"
5
- title Pings
5
+ title Finch
6
6
  link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css" rel="stylesheet"
7
+ meta http-equiv="refresh" content="30"
7
8
  body
8
9
  .container
9
10
  header class="jumbotron subhead" id="overview"
@@ -14,8 +15,12 @@ html
14
15
  th Name
15
16
  th State
16
17
  th Last success
17
- - pings.each do |ping|
18
- tr class="#{class_for_status(ping.state)}"
19
- td= ping.name
20
- td= ping.state
21
- td= ping.last_success
18
+ - pings.group_by(&:group).each do |group|
19
+ tr
20
+ th colspan=3
21
+ = group.first
22
+ - group.last.each do |ping|
23
+ tr class="#{class_for_status(ping.state)}"
24
+ td= ping.name
25
+ td= ping.state
26
+ td= ping.last_success
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-08 00:00:00.000000000 Z
12
+ date: 2013-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid