my_nagios 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/my_nagios/checks.coffee +18 -0
- data/app/assets/stylesheets/my_nagios/checks.scss +13 -0
- data/app/controllers/my_nagios/checks_controller.rb +16 -0
- data/app/jobs/schedule_by_interval_job.rb +1 -1
- data/app/models/my_nagios/check.rb +2 -1
- data/app/views/my_nagios/checks/_check_row.haml +14 -3
- data/app/views/my_nagios/welcome/index.haml +29 -8
- data/config/routes.rb +2 -1
- data/db/migrate/20160823134410_add_snooze_for_check.rb +5 -0
- data/lib/my_nagios/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9928548b5874bca05dd4fabc05972fde4a50913
|
4
|
+
data.tar.gz: f0c88b2b2c1e6651f7e95f4e5a12e48f7ffd6aea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0066bb8dcc6a7d74bb345907ec0682496fbf57f28e5aba5fc54bd354070e4e30829b5c97d53242df16e8510cbed168d308048069509bbd358dad4901b302890
|
7
|
+
data.tar.gz: 2dc32a663f977e82b0d94a79ed1568723fa3ac9692330f0789da385240330d5afaaf32449f93cb5e7a89379e23d17e7bd42e6f93cc89ca195b5ff4cb9fdd720f
|
@@ -1,9 +1,27 @@
|
|
1
1
|
$ ->
|
2
2
|
$('img.spinner').hide()
|
3
3
|
|
4
|
+
# Group Check Action
|
5
|
+
$('#group_action').hide()
|
6
|
+
$('#snooze_time_select').hide()
|
7
|
+
|
8
|
+
$('#check_group_action').change (event) ->
|
9
|
+
if $(this).val() == 'Snooze for' then $('#snooze_time_select').show() else $('#snooze_time_select').hide()
|
10
|
+
|
4
11
|
$('.check_now').click (event) ->
|
5
12
|
onclick_check_now(event)
|
6
13
|
|
14
|
+
$(':checkbox').change (event) ->
|
15
|
+
if $('input:checked').length > 0
|
16
|
+
$('#group_action').show();
|
17
|
+
selected_ids = $('input:checked').map () ->
|
18
|
+
return $(this).val()
|
19
|
+
|
20
|
+
$('#group_action_check_ids').val(selected_ids.get() + '')
|
21
|
+
else
|
22
|
+
$('#group_action').hide();
|
23
|
+
|
24
|
+
|
7
25
|
@onclick_check_now = (event) ->
|
8
26
|
$(event.target).closest('tr').addClass('updating')
|
9
27
|
$(event.target).closest('tr').find('img.spinner').show()
|
@@ -38,6 +38,22 @@ module MyNagios
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def group_action
|
42
|
+
check_ids = params["group_action_check_ids"].split(',')
|
43
|
+
redirect_to root_path and return if check_ids.blank?
|
44
|
+
|
45
|
+
case params['check_group_action'].downcase
|
46
|
+
when 'disable'
|
47
|
+
Check.where(id: check_ids).update_all(enabled: false)
|
48
|
+
when 'enable'
|
49
|
+
Check.where(id: check_ids).update_all(enabled: true)
|
50
|
+
when 'snooze for'
|
51
|
+
Check.where(id: check_ids).update_all(snooze_for: (Time.now + params['snooze_time_select'].to_i.minutes))
|
52
|
+
end
|
53
|
+
|
54
|
+
redirect_to root_path
|
55
|
+
end
|
56
|
+
|
41
57
|
private
|
42
58
|
|
43
59
|
def find_check
|
@@ -15,7 +15,7 @@ class ScheduleByIntervalJob
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# Optimized variant, group checks, run all necessary checks with one ssh connection
|
18
|
-
MyNagios::Check.enabled.where(interval: options['interval']).group_by{|check| { host: check.host, user: check.user, pem_key: check.pem_key } }.each do |config, checks|
|
18
|
+
MyNagios::Check.enabled.not_snoozed.where(interval: options['interval']).group_by{|check| { host: check.host, user: check.user, pem_key: check.pem_key } }.each do |config, checks|
|
19
19
|
MonitoringJob.perform_async(checks.map(&:id), config)
|
20
20
|
end
|
21
21
|
end
|
@@ -5,7 +5,8 @@ module MyNagios
|
|
5
5
|
enum status: [ :info, :success, :critical ]
|
6
6
|
enum state: [ :completed, :running ]
|
7
7
|
|
8
|
-
scope :enabled,
|
8
|
+
scope :enabled, -> { where(enabled: true) }
|
9
|
+
scope :not_snoozed, -> { where('`my_nagios_checks`.`snooze_for` <= NOW() OR `my_nagios_checks`.`snooze_for` IS NULL') }
|
9
10
|
|
10
11
|
attr_accessor :additional_command_result
|
11
12
|
|
@@ -1,9 +1,12 @@
|
|
1
1
|
- run_now ||= false
|
2
2
|
- show_group ||= false
|
3
|
+
- is_snooze = check.snooze_for and check.snooze_for > Time.now
|
3
4
|
|
4
5
|
- tr_id = show_group ? nil : dom_id(check)
|
6
|
+
- tr_html_class = check.enabled? ? 'enabled' : 'disabled'
|
7
|
+
- tr_html_class += ' alert alert-info' if is_snooze
|
5
8
|
|
6
|
-
%tr{ id: tr_id, class:
|
9
|
+
%tr{ id: tr_id, class: tr_html_class }
|
7
10
|
- if show_group
|
8
11
|
%td
|
9
12
|
=link_to check.group.name, "##{dom_id(check)}", class: 'fail_check'
|
@@ -13,10 +16,14 @@
|
|
13
16
|
="(regexp: #{check.regexp})" unless check.regexp.blank?
|
14
17
|
%p.check_interval= "run every: #{check.interval} min"
|
15
18
|
|
16
|
-
%td
|
19
|
+
%td{ class: is_snooze ? 'snooze_for' : '' }
|
17
20
|
%span.label{ class: "label-#{status_to_label(check.status)}"}= check.status
|
18
21
|
=check.latest_state
|
19
22
|
|
23
|
+
- if is_snooze
|
24
|
+
%div.snooze_for
|
25
|
+
Snooze for: #{check.snooze_for}
|
26
|
+
|
20
27
|
- if show_group
|
21
28
|
%strong=check.command
|
22
29
|
|
@@ -30,4 +37,8 @@
|
|
30
37
|
#actions
|
31
38
|
%br
|
32
39
|
=link_to 'edit', edit_check_path(check)
|
33
|
-
=link_to (check.enabled? ? 'disable' : 'enable' ), toggle_check_path(check), class: 'disable_check', method: :post, data: { remote: true, confirm: 'Are you sure?' }
|
40
|
+
=link_to (check.enabled? ? 'disable' : 'enable' ), toggle_check_path(check), class: 'disable_check', method: :post, data: { remote: true, confirm: 'Are you sure?' }
|
41
|
+
|
42
|
+
%td
|
43
|
+
.checkbox_holder
|
44
|
+
=check_box_tag dom_id(check), check.id
|
@@ -2,16 +2,37 @@
|
|
2
2
|
|
3
3
|
= render partial: 'failures_list', locals: { criticals: @criticals, show_group: true }
|
4
4
|
|
5
|
+
#group_action.text-center.alert.alert-warning{ role: :alert }
|
6
|
+
=form_tag group_action_path do
|
7
|
+
Please, set action for selected checks:
|
8
|
+
=select_tag :check_group_action, options_for_select(['Disable', 'Enable', 'Snooze for'])
|
9
|
+
=select_tag :snooze_time_select, options_for_select(['15 min', '30 min', '60 min'])
|
10
|
+
=hidden_field_tag :group_action_check_ids
|
11
|
+
=submit_tag
|
12
|
+
|
13
|
+
|
14
|
+
|
5
15
|
#checks{ data: :no_turbolink }
|
6
|
-
|
16
|
+
%table.table.check_list
|
17
|
+
%colgroup
|
18
|
+
%col{ width: '10%'}
|
19
|
+
%col{ width: '78%'}
|
20
|
+
%col{ width: '5%'}
|
21
|
+
%col{ width: '5%'}
|
22
|
+
%col{ width: '2%'}
|
23
|
+
%tr
|
24
|
+
%td
|
25
|
+
%td
|
26
|
+
%td
|
27
|
+
%td
|
28
|
+
%td
|
29
|
+
.checkbox_holder
|
30
|
+
=check_box_tag :select_all
|
7
31
|
|
8
|
-
|
32
|
+
- @group.each do |group|
|
33
|
+
%tr
|
34
|
+
%td{ colspan: 5 }
|
35
|
+
%h3=group.name
|
9
36
|
|
10
|
-
%table.table.check_list
|
11
|
-
%colgroup
|
12
|
-
%col{ width: '10%'}
|
13
|
-
%col{ width: '80%'}
|
14
|
-
%col{ width: '5%'}
|
15
|
-
%col{ width: '5%'}
|
16
37
|
- group.checks.each do |check|
|
17
38
|
= render partial: '/my_nagios/checks/check_row', locals: { check: check, run_now: true }
|
data/config/routes.rb
CHANGED
@@ -3,7 +3,8 @@ MyNagios::Engine.routes.draw do
|
|
3
3
|
mount Sidekiq::Web, at: '/sidekiq'
|
4
4
|
|
5
5
|
root 'welcome#index'
|
6
|
-
match 'autorefresh',
|
6
|
+
match 'autorefresh', to: 'welcome#autorefresh', via: [:post]
|
7
|
+
match 'group_action', to: 'checks#group_action', via: [:post]
|
7
8
|
|
8
9
|
resources :checks do
|
9
10
|
member do
|
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.19
|
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-08-
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- db/migrate/20160503110441_create_my_nagios_groups.rb
|
196
196
|
- db/migrate/20160601081654_add_regexp_to_check.rb
|
197
197
|
- db/migrate/20160621080454_additional_command.rb
|
198
|
+
- db/migrate/20160823134410_add_snooze_for_check.rb
|
198
199
|
- lib/my_nagios.rb
|
199
200
|
- lib/my_nagios/engine.rb
|
200
201
|
- lib/my_nagios/version.rb
|