my_nagios 0.0.13 → 0.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54ccb4307766b97a56702ff3be5b2af13b9f34c6
4
- data.tar.gz: 826050115c2a120f1bc0b812af78f22db1f44eb1
3
+ metadata.gz: 08675c59ec122b34650ee7c21c7218af30ef7d3f
4
+ data.tar.gz: 6f9e8ea47b9b8479717f96071bb8d61fadfcf0d6
5
5
  SHA512:
6
- metadata.gz: 68b5a1a4921f1e0bcf7d0a5a25d7d09a195380cb61364443acb37ee1e79bf7592861c3778c8fb94fa9579e6234784130405b2ddb557d865ee915a07e14725235
7
- data.tar.gz: 05466c1c0469bc6c60363575e0e07a72bfce83c1392763d1f7a6ee4b63f65d57718ad547b72ffa1488a2ad7541bcca33145550967641975f9f32b09423bfef95
6
+ metadata.gz: 78340047fcaa7568bbafc843576160fc8e93606afd41def2ec9ab1bd9c27162dde607d13f4c6cba86ee16404955784285ba53a18a8b27087aa5b37b70ff3b0c8
7
+ data.tar.gz: d958f8248b1c8891990cc9fab96c858fd41e7f219930a54622618d2d0e7e8c910782bf074449cb36f3c59ea44cbb21e666c83eb1126b4d63f26799307f76adeb
@@ -3,7 +3,7 @@ require_dependency "my_nagios/application_controller"
3
3
  module MyNagios
4
4
  class ChecksController < ApplicationController
5
5
  before_filter :find_check, only: [:run_now, :toggle, :edit, :update]
6
- before_filter :find_groups, only: [:create, :edit]
6
+ before_filter :find_groups, only: [:new, :create, :edit]
7
7
 
8
8
  def new
9
9
  @check = Check.new
@@ -49,7 +49,7 @@ module MyNagios
49
49
  end
50
50
 
51
51
  def params_check
52
- params.require(:check).permit(:host, :user, :pem_key, :description, :interval, :command, :regexp, :group_id)
52
+ params.require(:check).permit(:host, :user, :pem_key, :description, :interval, :command, :additional_command, :regexp, :group_id)
53
53
  end
54
54
  end
55
55
  end
@@ -7,13 +7,19 @@ module MyNagios
7
7
 
8
8
  scope :enabled, -> { where(enabled: true) }
9
9
 
10
+ attr_accessor :additional_command_result
11
+
10
12
  def run!
11
13
  begin
12
14
  self.update(state: :running)
13
15
 
14
16
  Net::SSH.start( self.host, self.user, config: true, keys: [self.pem_key], non_interactive: true ) do| ssh |
15
17
  result = ssh.exec! self.command
16
- self.update(state: :completed, status: self.determinate_status_by_response(result), latest_state: result, latest_updated_at: Time.now)
18
+ status = self.determinate_status_by_response(result)
19
+
20
+ self.additional_command_result = ssh.exec!(self.additional_command) if not self.additional_command.blank? and status.eql?(:critical)
21
+
22
+ self.update(state: :completed, status: status, latest_state: result, latest_updated_at: Time.now)
17
23
  end
18
24
  rescue => e
19
25
  self.update(state: :completed, status: :info, latest_state: e, latest_updated_at: Time.now)
@@ -29,7 +35,11 @@ module MyNagios
29
35
  Net::SSH.start( config['host'], config['user'], config: true, keys: [config['pem_key']], non_interactive: true ) do |ssh|
30
36
  check_list.each do |check|
31
37
  result = ssh.exec! check.command
32
- check.update(state: :completed, status: check.determinate_status_by_response(result), latest_state: result, latest_updated_at: Time.now)
38
+ status = check.determinate_status_by_response(result)
39
+
40
+ check.additional_command_result = ssh.exec!(check.additional_command) if not check.additional_command.blank? and status.eql?(:critical)
41
+
42
+ check.update(state: :completed, status: status, latest_state: result, latest_updated_at: Time.now)
33
43
  end
34
44
  end
35
45
 
@@ -36,6 +36,11 @@
36
36
  .col-sm-10
37
37
  =f.text_field :command, class: 'form-control'
38
38
 
39
+ .form-group
40
+ =f.label :additional_command, 'Additional command (runs if command is fail)', class: 'col-sm-1 control-label'
41
+ .col-sm-10
42
+ =f.text_field :additional_command, class: 'form-control'
43
+
39
44
  .form-group
40
45
  =f.label :regexp, 'Critical if match:', class: 'col-sm-1 control-label'
41
46
  .col-sm-10
@@ -0,0 +1,5 @@
1
+ class AdditionalCommand < ActiveRecord::Migration
2
+ def change
3
+ add_column :my_nagios_checks, :additional_command, :text, default: nil
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module MyNagios
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
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.13
4
+ version: 0.0.14
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-06-16 00:00:00.000000000 Z
11
+ date: 2016-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -193,6 +193,7 @@ files:
193
193
  - db/migrate/20160503110437_create_my_nagios_checks.rb
194
194
  - db/migrate/20160503110441_create_my_nagios_groups.rb
195
195
  - db/migrate/20160601081654_add_regexp_to_check.rb
196
+ - db/migrate/20160621080454_additional_command.rb
196
197
  - lib/my_nagios.rb
197
198
  - lib/my_nagios/engine.rb
198
199
  - lib/my_nagios/version.rb