oggle 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NWQ3ZGY2MzlhZWViMGY2NzhmOGEzNGE4NmMwZDE4MTM5ZjIzZjYyZg==
5
+ data.tar.gz: !binary |-
6
+ ODM5ZTVmMDEwYWQ1Yjk5NzU3ZGQzOTFhNzUzZDJjM2ZhYmJjYjUwOQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MTRiNjE0NDYwZDUzNDJmMTE2ZmY2MGU1MDg3NmJmNzhlMDYyNmJmNzc0MzVi
10
+ NTViYjI5ZDA5NGEzNzA5ODYwNjAxYTI1YTExMDBhYjBjYmFmMGNkZDEyZDVm
11
+ YWViM2YyNDA2YjMyOGE4NTZkODA2NjQ1ODQ0ODdmZmJlYTg2Yzg=
12
+ data.tar.gz: !binary |-
13
+ ODNlM2M2MTdjYzRlZWUyYjZiYjM5Y2Q3Mzg0ODBhMGIwMDBhYjZiZDJlYTU4
14
+ YTk3MDg0YjAxOWMzODgzMzExYTJiN2NmZGRmMTIyOWRhYzk5YTZmMDFhNjgy
15
+ MGRhNTkwMDRhYWVhYWMyZjkyOGQyMTVjYmIzMjcyY2VjMmQ3M2Y=
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in watch.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # Oggle
2
+
3
+ Oggle is a simple tool to monitor servers. Just point it to a YAML file containing a list of servers and words to check for, and Oggle will monitor the servers uptime and show it on a webpage.
4
+
5
+ ## Installation
6
+
7
+ gem install oggle
8
+
9
+ ## Installing on Windows
10
+ To install Oggle on windows, install the DevKit (http://rubyforge.org/frs/download.php/76805/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe) and run the
11
+ <installed_dir>ruby dk.rb init
12
+ <installed_dir>ruby dk.rb install
13
+
14
+ before installation.
15
+
16
+
17
+ ## Usage
18
+
19
+ oggle start [--port <port>] <file.yaml>
20
+
21
+ ## File format
22
+
23
+ servers:
24
+ <servername>:
25
+ url:<url>
26
+ check:<string to check response for>
27
+ ...
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'cli'
3
+
@@ -0,0 +1,27 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+
3
+ require 'sinatra'
4
+ require 'thor'
5
+ require 'oggle'
6
+ require 'yaml'
7
+
8
+ module Oggle
9
+ class CLI < Thor
10
+ desc "start FILE", "Start the Oggle server watching files in FILE."
11
+ method_option :port,:aliases => "-p", :desc => "Webserver port"
12
+ def start(file)
13
+ servers = YAML.load_file(file)
14
+ Oggle::App.run!(
15
+ servers: servers['servers'],
16
+ interval: servers['interval'],
17
+ port: options[:port]||4567,
18
+ run: false,
19
+ server: 'thin',
20
+ sockets: [],
21
+ root: Proc.new { File.join(File.dirname(__FILE__), "..") }
22
+ )
23
+ end
24
+ end
25
+ end
26
+
27
+ Oggle::CLI.start(ARGV)
@@ -0,0 +1,68 @@
1
+ require "oggle/version"
2
+ require 'sinatra/base'
3
+ require 'sinatra-websocket'
4
+ require 'em-http-request'
5
+ require 'json'
6
+
7
+ module Oggle
8
+ class App < Sinatra::Base
9
+ def self.poll(servers)
10
+ servers.each do|server|
11
+ http = EM::HttpRequest.new(server[1]['url']).get :redirects => 5
12
+ http.errback do
13
+ EM.next_tick { settings.sockets.each{|s| s.send(create_message(server, 'error').to_json)}}
14
+ server[1]['status'] = 'error'
15
+ end
16
+ http.callback do
17
+ status = 'error'
18
+ status = 'ok' if http.response.to_s.include?(server[1]['check'])
19
+ #status = rand(3)==1?'error':'ok'
20
+ EM.next_tick { settings.sockets.each{|s| s.send(create_message(server, status).to_json)}}
21
+ server[1]['status'] = status
22
+ end
23
+ end
24
+ end
25
+
26
+ def self.create_message(server, status)
27
+ {
28
+ type:"update",
29
+ name: server[0],
30
+ server:{url: server[1]['url'],
31
+ status: status
32
+ }}
33
+ end
34
+
35
+ configure do
36
+ EM.next_tick do
37
+ Oggle::App.poll(settings.servers)
38
+ EM.add_periodic_timer settings.interval||30 do
39
+ Oggle::App.poll(settings.servers)
40
+ end
41
+ end
42
+ end
43
+ get '/' do
44
+ if !request.websocket?
45
+ erb :index, :locals => {:port => settings.port}
46
+ else
47
+ request.websocket do |ws|
48
+ ws.onopen do
49
+ ws.send({
50
+ type:"init",
51
+ servers: settings.servers
52
+ }.to_json)
53
+ settings.sockets << ws
54
+ end
55
+
56
+ #ws.onmessage do |msg|
57
+ # EM.next_tick { settings.sockets.each{|s| s.send(msg) } }
58
+ #end
59
+
60
+ ws.onclose do
61
+ warn("websocket closed")
62
+ settings.sockets.delete(ws)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,3 @@
1
+ module Watch
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'oggle/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "oggle"
8
+ gem.version = Watch::VERSION
9
+ gem.authors = ["Morten Wilken"]
10
+ gem.email = ["wilken@ultraplex.org"]
11
+ gem.description = "Small utility for watching the liveness of URLs"
12
+ gem.summary = "Small utility for watching the liveness of URLs"
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency "eventmachine", "=1.0.1"
21
+ gem.add_runtime_dependency "sinatra", "=1.3.5"
22
+ gem.add_runtime_dependency "sinatra-websocket", "=0.2.1"
23
+ gem.add_runtime_dependency "em-http-request", "=1.0.3"
24
+ gem.add_runtime_dependency "thin", "=1.5.0"
25
+ gem.add_runtime_dependency "thor", "=0.17.0"
26
+ gem.add_runtime_dependency "json", "=1.7.7"
27
+
28
+ end
@@ -0,0 +1,50 @@
1
+ var watch = angular.module('Oggle', [])
2
+ watch.factory('websocket', function($rootScope, $location) {
3
+ var ws = new WebSocket("ws://localhost:"+$location.port());
4
+ return {
5
+ onmessage: function(fn) {
6
+ ws.onmessage = function(event) {
7
+ $rootScope.$apply(function() {
8
+ fn(ws,event);
9
+ });
10
+ }
11
+ },
12
+ send: ws.send,
13
+ onopen:function(fn) {
14
+ ws.onopen = function(event) {
15
+ $rootScope.$apply(function() {
16
+ fn(ws, event);
17
+ });
18
+ }
19
+ },
20
+ onclose: function(fn) {
21
+ ws.onclose = function(event) {
22
+ $rootScope.$apply(function() {
23
+ fn(ws,event);
24
+ });
25
+ }
26
+ }
27
+ }
28
+ })
29
+
30
+ watch.controller('OggleCtrl', function($scope, websocket) {
31
+ console.log("starting controller")
32
+ $scope.servers ={}
33
+ websocket.onmessage(function(ws,event) {
34
+ var json = JSON.parse(event.data)
35
+ switch(json['type']) {
36
+ case 'init':
37
+ $scope.servers = json['servers']
38
+ break;
39
+ case 'update':
40
+ $scope.servers[json['name']]['status'] = json['server']['status']
41
+ break;
42
+ }
43
+ })
44
+ websocket.onclose(function(ws, event) {
45
+ console.log("socket closed");
46
+ })
47
+ websocket.onopen(function(ws,event) {
48
+ ws.send("hello server");
49
+ })
50
+ })
@@ -0,0 +1,11 @@
1
+ servers:
2
+ Ekstra bladet:
3
+ url: http://eb.dks
4
+ check: fodbold
5
+ Politiken:
6
+ url: http://politiken.dk
7
+ check: fodbold
8
+ Google:
9
+ url: https://google.com
10
+ check: google
11
+ interval: 30
@@ -0,0 +1,28 @@
1
+ <html>
2
+ <head>
3
+ <script src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>
4
+ <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script>
5
+ <script src="js/app.js"></script>
6
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
7
+ <title>Oggle.</title>
8
+ </head>
9
+ <body class="container" ng-app="Oggle" style="margin-top:40px">
10
+ <h2>Oggle.</h2>
11
+ <table class="table table-striped well" style="margin-bottom:0px" ng-controller="OggleCtrl">
12
+ <tr>
13
+ <th>Server</th>
14
+ <th>URL</th>
15
+ <th width="100px">Status</th>
16
+ </tr>
17
+ <tr ng:repeat="(key, value) in servers">
18
+ <td>{{key}}</td>
19
+ <td>{{value.url}}</td>
20
+ <td>
21
+ <span ng-show="value.status=='ok'" class="label label-success">Success</span>
22
+ <span ng-show="value.status=='error'" class="label label-important">Failed</span>
23
+ </td>
24
+ </tr>
25
+ </table>
26
+ <div style="text-align:right;color:#999999">unusual.io</div>
27
+ </body>
28
+ </html>
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oggle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Morten Wilken
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: eventmachine
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra-websocket
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: em-http-request
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: thin
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.5.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.5.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.17.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.17.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.7.7
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.7.7
111
+ description: Small utility for watching the liveness of URLs
112
+ email:
113
+ - wilken@ultraplex.org
114
+ executables:
115
+ - oggle
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - .gitignore
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - bin/oggle
125
+ - lib/cli.rb
126
+ - lib/oggle.rb
127
+ - lib/oggle/version.rb
128
+ - oggle.gemspec
129
+ - public/js/app.js
130
+ - servers.yml
131
+ - views/index.erb
132
+ homepage: ''
133
+ licenses: []
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.0.1
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Small utility for watching the liveness of URLs
155
+ test_files: []