my_nagios 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/my_nagios/checks.coffee +1 -3
- data/app/assets/javascripts/my_nagios/welcome.coffee +25 -0
- data/app/assets/stylesheets/my_nagios/welcome.scss +20 -0
- data/app/controllers/my_nagios/checks_controller.rb +22 -3
- data/app/controllers/my_nagios/welcome_controller.rb +15 -2
- data/app/models/my_nagios/check.rb +2 -0
- data/app/views/layouts/my_nagios/application.haml +1 -1
- data/app/views/my_nagios/checks/_check_row.haml +8 -3
- data/app/views/my_nagios/checks/_form.haml +24 -0
- data/app/views/my_nagios/checks/edit.haml +3 -0
- data/app/views/my_nagios/checks/new.haml +1 -24
- data/app/views/my_nagios/checks/run_now.js.coffee +1 -5
- data/app/views/my_nagios/checks/toggle.js.coffee +7 -0
- data/app/views/my_nagios/welcome/_failures_list.haml +16 -0
- data/app/views/my_nagios/welcome/autorefresh.coffee +1 -0
- data/app/views/my_nagios/welcome/index.haml +2 -13
- data/config/routes.rb +3 -0
- data/lib/my_nagios/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 358b8883d69c7d489a7662a3da495907efc3dae3
|
4
|
+
data.tar.gz: a7f10106f444595ad53b5e0efdb1fc8af7ac3881
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d23398061c02968b1428b60357c3a16eeded5e1f8c5f4ae46c199a717a7408387ac6ee09ebde7c25bc9511591fac7dba2dc8b6c76930761ff77e001c5031880
|
7
|
+
data.tar.gz: 4998de0dbefbba5d6cb4f5c220ea7009b54a40763051b8d4d90b6da53e17a5ff60432116791940884fe7f38698b2d9df0115f2a9ed310560da6e1ea3f146b33e
|
@@ -0,0 +1,25 @@
|
|
1
|
+
$ ->
|
2
|
+
refresh_rate = 15000
|
3
|
+
|
4
|
+
setInterval () ->
|
5
|
+
$('table.failures_list').addClass('refresing')
|
6
|
+
show_timer(refresh_rate)
|
7
|
+
|
8
|
+
$.ajax
|
9
|
+
url: '/autorefresh'
|
10
|
+
type: "POST"
|
11
|
+
dataType: "script"
|
12
|
+
, refresh_rate
|
13
|
+
|
14
|
+
show_timer = (counter) ->
|
15
|
+
counter = (counter / 1000) % 60
|
16
|
+
|
17
|
+
interval = setInterval () ->
|
18
|
+
counter -= 1
|
19
|
+
|
20
|
+
clearInterval(interval) if counter == 0
|
21
|
+
|
22
|
+
$('#failures_list .timer').html(counter)
|
23
|
+
, 1000
|
24
|
+
|
25
|
+
$(document).ready(show_timer(refresh_rate))
|
@@ -8,4 +8,24 @@
|
|
8
8
|
* {
|
9
9
|
font-size: 0.9em;
|
10
10
|
}
|
11
|
+
|
12
|
+
#failures_list {
|
13
|
+
position: relative;
|
14
|
+
|
15
|
+
.timer {
|
16
|
+
position: absolute;
|
17
|
+
top: 8px;
|
18
|
+
right: 8px;
|
19
|
+
}
|
20
|
+
|
21
|
+
table.failures_list.refresing {
|
22
|
+
color: #e6e6e6;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
table.check_list {
|
27
|
+
tr.disabled {
|
28
|
+
background-color: #e6e6e6;
|
29
|
+
}
|
30
|
+
}
|
11
31
|
}
|
@@ -2,6 +2,8 @@ require_dependency "my_nagios/application_controller"
|
|
2
2
|
|
3
3
|
module MyNagios
|
4
4
|
class ChecksController < ApplicationController
|
5
|
+
before_filter :find_check, only: [:run_now, :toggle, :edit, :create, :update]
|
6
|
+
|
5
7
|
def new
|
6
8
|
@check = Check.new
|
7
9
|
end
|
@@ -11,10 +13,15 @@ module MyNagios
|
|
11
13
|
redirect_to root_path
|
12
14
|
end
|
13
15
|
|
14
|
-
def
|
15
|
-
|
16
|
-
return unless @check
|
16
|
+
def edit
|
17
|
+
end
|
17
18
|
|
19
|
+
def update
|
20
|
+
@check.update(params_check)
|
21
|
+
redirect_to root_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_now
|
18
25
|
@check.run!
|
19
26
|
|
20
27
|
respond_to do |format|
|
@@ -22,8 +29,20 @@ module MyNagios
|
|
22
29
|
end
|
23
30
|
end
|
24
31
|
|
32
|
+
def toggle
|
33
|
+
@check.toggle! :enabled
|
34
|
+
|
35
|
+
respond_to do |format|
|
36
|
+
format.js { render layout: false }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
25
40
|
private
|
26
41
|
|
42
|
+
def find_check
|
43
|
+
@check = Check.find(params[:id])
|
44
|
+
end
|
45
|
+
|
27
46
|
def params_check
|
28
47
|
params.require(:check).permit(:host, :user, :pem_key, :description, :interval, :command)
|
29
48
|
end
|
@@ -3,9 +3,22 @@ require_dependency "my_nagios/application_controller"
|
|
3
3
|
module MyNagios
|
4
4
|
class WelcomeController < ApplicationController
|
5
5
|
|
6
|
+
before_filter :find_criticals, only: [:index, :autorefresh]
|
7
|
+
|
6
8
|
def index
|
7
|
-
@group
|
8
|
-
|
9
|
+
@group = Group.all.includes(:checks)
|
10
|
+
end
|
11
|
+
|
12
|
+
def autorefresh
|
13
|
+
respond_to do |format|
|
14
|
+
format.js { render layout: false }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def find_criticals
|
21
|
+
@criticals = Check.enabled.where(status: Check.statuses[:critical])
|
9
22
|
end
|
10
23
|
|
11
24
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
- run_now ||= false
|
2
2
|
- show_group ||= false
|
3
3
|
|
4
|
-
%tr{ id: dom_id(check) }
|
4
|
+
%tr{ id: dom_id(check), class: (check.enabled? ? 'enabled' : 'disabled') }
|
5
5
|
- if show_group
|
6
6
|
%td
|
7
7
|
%strong=check.group.name
|
@@ -19,5 +19,10 @@
|
|
19
19
|
|
20
20
|
- if run_now
|
21
21
|
%td
|
22
|
-
|
23
|
-
|
22
|
+
#check_now
|
23
|
+
=link_to 'run now', run_now_check_path(check), class: 'check_now', method: :post, remote: true
|
24
|
+
=image_tag 'my_nagios/chasing_arrows.gif', class: 'spinner'
|
25
|
+
#actions
|
26
|
+
%br
|
27
|
+
=link_to 'edit', edit_check_path(check)
|
28
|
+
=link_to (check.enabled? ? 'disable' : 'enable' ), toggle_check_path(check), class: 'disable_check', method: :post, data: { remote: true, confirm: 'Are you sure?' }
|
@@ -0,0 +1,24 @@
|
|
1
|
+
=form_for @check do |f|
|
2
|
+
=f.label :group
|
3
|
+
=f.select :group, options_for_select( MyNagios::Group.all.map{|g| [g.name, g.id]} )
|
4
|
+
%br
|
5
|
+
=f.label :host
|
6
|
+
=f.text_field :host
|
7
|
+
%br
|
8
|
+
=f.label :user
|
9
|
+
=f.text_field :user
|
10
|
+
%br
|
11
|
+
=f.label :pem_key
|
12
|
+
=f.text_field :pem_key
|
13
|
+
%br
|
14
|
+
=f.label :description
|
15
|
+
=f.text_field :description
|
16
|
+
%br
|
17
|
+
=f.label :interval
|
18
|
+
=f.text_field :interval
|
19
|
+
%br
|
20
|
+
=f.label :command
|
21
|
+
=f.text_field :command
|
22
|
+
%br
|
23
|
+
|
24
|
+
=f.submit
|
@@ -1,26 +1,3 @@
|
|
1
1
|
Add new check
|
2
2
|
|
3
|
-
=
|
4
|
-
=f.label :group
|
5
|
-
=f.select :group, options_for_select( MyNagios::Group.all.map{|g| [g.name, g.id]} )
|
6
|
-
%br
|
7
|
-
=f.label :host
|
8
|
-
=f.text_field :host
|
9
|
-
%br
|
10
|
-
=f.label :user
|
11
|
-
=f.text_field :user
|
12
|
-
%br
|
13
|
-
=f.label :pem_key
|
14
|
-
=f.text_field :pem_key
|
15
|
-
%br
|
16
|
-
=f.label :description
|
17
|
-
=f.text_field :description
|
18
|
-
%br
|
19
|
-
=f.label :interval
|
20
|
-
=f.text_field :interval
|
21
|
-
%br
|
22
|
-
=f.label :command
|
23
|
-
=f.text_field :command
|
24
|
-
%br
|
25
|
-
|
26
|
-
=f.submit
|
3
|
+
= render partial: 'form'
|
@@ -5,8 +5,4 @@ tr = '<%= dom_id(@check) %>'
|
|
5
5
|
$('#' + tr).find('img.spinner').hide()
|
6
6
|
|
7
7
|
$('#' + tr).find('a.check_now').click (event) ->
|
8
|
-
onclick_check_now(event)
|
9
|
-
|
10
|
-
onclick_check_now = (event) ->
|
11
|
-
$(event.target).closest('tr').addClass('updating')
|
12
|
-
$(event.target).closest('tr').find('img.spinner').show()
|
8
|
+
onclick_check_now(event)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#failures_list
|
2
|
+
.timer
|
3
|
+
%h3 Critical errors:
|
4
|
+
|
5
|
+
- if @criticals.blank?
|
6
|
+
%p No criticals
|
7
|
+
- else
|
8
|
+
|
9
|
+
%table.table.failures_list
|
10
|
+
%colgroup
|
11
|
+
%col{ width: '10%'}
|
12
|
+
%col{ width: '80%'}
|
13
|
+
%col{ width: '5%'}
|
14
|
+
%col{ width: '5%'}
|
15
|
+
- criticals.each do |check|
|
16
|
+
= render partial: '/my_nagios/checks/check_row', locals: { check: check, show_group: true }
|
@@ -0,0 +1 @@
|
|
1
|
+
$('#failures_list').replaceWith('<%= j render(partial: '/my_nagios/welcome/failures_list', locals: { criticals: @criticals, show_group: true }) %>')
|
@@ -1,24 +1,13 @@
|
|
1
1
|
=link_to 'Add new check', new_check_path
|
2
2
|
|
3
|
-
|
4
|
-
- if @criticals.blank?
|
5
|
-
%p No criticals
|
6
|
-
- else
|
7
|
-
%table.table
|
8
|
-
%colgroup
|
9
|
-
%col{ width: '10%'}
|
10
|
-
%col{ width: '80%'}
|
11
|
-
%col{ width: '5%'}
|
12
|
-
%col{ width: '5%'}
|
13
|
-
- @criticals.each do |check|
|
14
|
-
= render partial: '/my_nagios/checks/check_row', locals: { check: check, show_group: true }
|
3
|
+
= render partial: 'failures_list', locals: { criticals: @criticals, show_group: true }
|
15
4
|
|
16
5
|
#checks{ data: :no_turbolink }
|
17
6
|
- @group.each do |group|
|
18
7
|
|
19
8
|
%h3=group.name
|
20
9
|
|
21
|
-
%table.table
|
10
|
+
%table.table.check_list
|
22
11
|
%colgroup
|
23
12
|
%col{ width: '10%'}
|
24
13
|
%col{ width: '80%'}
|
data/config/routes.rb
CHANGED
data/lib/my_nagios/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_nagios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Omelchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -179,8 +179,13 @@ files:
|
|
179
179
|
- app/models/my_nagios/group.rb
|
180
180
|
- app/views/layouts/my_nagios/application.haml
|
181
181
|
- app/views/my_nagios/checks/_check_row.haml
|
182
|
+
- app/views/my_nagios/checks/_form.haml
|
183
|
+
- app/views/my_nagios/checks/edit.haml
|
182
184
|
- app/views/my_nagios/checks/new.haml
|
183
185
|
- app/views/my_nagios/checks/run_now.js.coffee
|
186
|
+
- app/views/my_nagios/checks/toggle.js.coffee
|
187
|
+
- app/views/my_nagios/welcome/_failures_list.haml
|
188
|
+
- app/views/my_nagios/welcome/autorefresh.coffee
|
184
189
|
- app/views/my_nagios/welcome/index.haml
|
185
190
|
- config/initializers/sidekiq.rb
|
186
191
|
- config/routes.rb
|