my_nagios 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba4f50f6cc3f9dd7fee7469107733dca82ffeb0c
4
- data.tar.gz: 9ac66821b232b0b0729288eeb482a1416e9422ed
3
+ metadata.gz: b637570a04fd2adb5def00b3f8cfd77ad3f1679e
4
+ data.tar.gz: 0c52e8509e3e5604970a159b002a3bed9a118155
5
5
  SHA512:
6
- metadata.gz: d4f7dcf8b450d3325f72a6341442d6afbbae1cb7a41c26060d4b9152df251b0f32a34ad65cb4fb375cec7a5cc9f6d58760b027e34f5a4f4e2bf8f44cc107885f
7
- data.tar.gz: 68dafde5cfb3c71916e60c395a117fd2abe934f9e73406f85c0064f25737751c4f2c7957da33cc4f4ad64e62bcb910f5de6d4ca95e39c7396e56c983871bb8b6
6
+ metadata.gz: 15964788d84148d14e5a46da1d0a9b91bedc93128b5cf206dc77d63bef1cf98722d8ee8f259d738e67ff38fed5bc45d413b99d6a5978598753dd9998a3282c01
7
+ data.tar.gz: 3ed140d7131a60ae6382ee991f44d74b6e184474976d7d4ff77e335b1085537171cfef0e2680d172665a851bf551b6554575ad20caa8bebf7bf4b54e69806be3
@@ -5,7 +5,8 @@ module MyNagios
5
5
  before_filter :find_check, only: [:run_now, :toggle, :edit, :update]
6
6
 
7
7
  def new
8
- @check = Check.new
8
+ @check = Check.new
9
+ @groups = MyNagios::Group.all
9
10
  end
10
11
 
11
12
  def create
@@ -44,7 +45,7 @@ module MyNagios
44
45
  end
45
46
 
46
47
  def params_check
47
- params.require(:check).permit(:host, :user, :pem_key, :description, :interval, :command)
48
+ params.require(:check).permit(:host, :user, :pem_key, :description, :interval, :command, :regexp, :group_id)
48
49
  end
49
50
  end
50
51
  end
@@ -13,7 +13,7 @@ module MyNagios
13
13
 
14
14
  Net::SSH.start( self.host, self.user, config: true, keys: [self.pem_key], non_interactive: true ) do| ssh |
15
15
  result = ssh.exec! self.command
16
- self.update(status: Check.determinate_status_by_response(result), latest_state: result, latest_updated_at: Time.now)
16
+ self.update(status: determinate_status_by_response(result), latest_state: result, latest_updated_at: Time.now)
17
17
  end
18
18
  rescue => e
19
19
  self.update(status: :info, latest_state: e, latest_updated_at: Time.now)
@@ -31,7 +31,7 @@ module MyNagios
31
31
  Net::SSH.start( config['host'], config['user'], config: true, keys: [config['pem_key']], non_interactive: true ) do |ssh|
32
32
  check_list.each do |check|
33
33
  result = ssh.exec! check.command
34
- check.update(status: Check.determinate_status_by_response(result), latest_state: result, latest_updated_at: Time.now)
34
+ check.update(status: determinate_status_by_response(result), latest_state: result, latest_updated_at: Time.now)
35
35
  end
36
36
  end
37
37
 
@@ -42,7 +42,10 @@ module MyNagios
42
42
  end
43
43
  end
44
44
 
45
- def self.determinate_status_by_response(response)
45
+ private
46
+
47
+ def determinate_status_by_response(response)
48
+ return :critical if not regexp.blank? and response =~ /#{regexp}/
46
49
  return :critical if not response.scan('CRITICAL').blank?
47
50
  return :info if response.nil? or not response.scan('No such file or directory').blank?
48
51
  :success
@@ -8,7 +8,9 @@
8
8
  %td
9
9
  =link_to check.group.name, "##{dom_id(check)}", class: 'fail_check'
10
10
  - else
11
- %td=check.command
11
+ %td
12
+ =check.command
13
+ ="(regexp: #{check.regexp})" unless check.regexp.blank?
12
14
 
13
15
  %td
14
16
  %span.label{ class: "label-#{status_to_label(check.status)}"}= check.status
@@ -1,9 +1,10 @@
1
1
  .row.col-sm-12
2
2
  =form_for @check, html: { class: 'form-horizontal' } do |f|
3
+
3
4
  .form-group
4
- =f.label :group, class: 'col-sm-1 control-label'
5
+ =f.label :group_id, class: 'col-sm-1 control-label'
5
6
  .col-sm-10
6
- =f.select :group, options_for_select( MyNagios::Group.all.map{|g| [g.name, g.id]}, @check.group_id ), class: 'form-control'
7
+ =f.select :group_id, options_for_select( @groups.map{|g| [g.name, g.id]}, @check.group_id ), class: 'form-control'
7
8
 
8
9
  .form-group
9
10
  =f.label :host, class: 'col-sm-1 control-label'
@@ -35,6 +36,11 @@
35
36
  .col-sm-10
36
37
  =f.text_field :command, class: 'form-control'
37
38
 
39
+ .form-group
40
+ =f.label :regexp, 'Critical if match:', class: 'col-sm-1 control-label'
41
+ .col-sm-10
42
+ =f.text_field :regexp, class: 'form-control'
43
+
38
44
  .form-group
39
45
  .col-sm-10.col-sm-offset-1
40
46
  =f.submit
@@ -0,0 +1,5 @@
1
+ class AddRegexpToCheck < ActiveRecord::Migration
2
+ def change
3
+ add_column :my_nagios_checks, :regexp, :string, default: nil
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module MyNagios
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
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.8
4
+ version: 0.0.9
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-25 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -192,6 +192,7 @@ files:
192
192
  - config/schedule.yml
193
193
  - db/migrate/20160503110437_create_my_nagios_checks.rb
194
194
  - db/migrate/20160503110441_create_my_nagios_groups.rb
195
+ - db/migrate/20160601081654_add_regexp_to_check.rb
195
196
  - lib/my_nagios.rb
196
197
  - lib/my_nagios/engine.rb
197
198
  - lib/my_nagios/version.rb