nagios_helper 0.2 → 0.2.1

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: 6b1d346c062988fe38d78c13e5b0acc695417d3b
4
- data.tar.gz: 5c7225e767d1122292e7def3ce87552e946c5e76
3
+ metadata.gz: 50e85dabbbacbf238168749d0430660be9ccf0b2
4
+ data.tar.gz: 328e497d63561066ae4b2fdf34ed4b0ab9a63992
5
5
  SHA512:
6
- metadata.gz: 282c265047ab2d6015e6eed5b85905cada8a31910af2e6cdf4a5c3c9e9395bc8cdb2537e18a743a5f0cbb0062745c278938e3a67808fa6abed4574ea1d6feb1a
7
- data.tar.gz: 67a8344b613ffd52775aa1630c7b39f298770d1649500d3fa9ec1d98a6fbc5b036b048953e0bcedfcc3c0ec06f800c27285c0f1fd55a6b7aea2d75623590ce00
6
+ metadata.gz: d81b1bc0b051ec6993c6059eb4d1153092d1676594e7a9c2b581e48fdc3dac14c687d85faeb06697361be13b961db1240c12ce1cc7e29f707e19c18d50d44f45
7
+ data.tar.gz: 5e6dafc07b8957f7723097dfbf2b3a9c2db80c23dab00d95b75d0487dc8de92acfc77a04e116b294430d6bb0236bb13d00f10fecba65f5baf152c894d622a1ca
data/lib/nagios/check.rb CHANGED
@@ -2,12 +2,14 @@ class Nagios::Check
2
2
 
3
3
  TYPES = %w{ok crit other warn} unless defined?(TYPES)
4
4
 
5
+ attr_reader :check_name
6
+
5
7
  def initialize(params = {}, &callback)
6
8
  @params = params.with_indifferent_access
7
9
  @callback = callback
8
10
  @started_at = Time.now
9
11
  @tag = "#{self.class.name}/#{params.inspect}"
10
- @check_name = self.class.name.underscore
12
+ @check_name = self.class.name.underscore.split("/").last
11
13
 
12
14
  logger.info "=> #{@tag}"
13
15
 
@@ -126,16 +128,7 @@ protected
126
128
 
127
129
  class << self
128
130
  def check_name
129
- @check_name ||= self.name.underscore
130
- end
131
-
132
- def url
133
- "http://localhost:3000/nagios/check?method=#{check_name}"
134
- end
135
-
136
- def interval
137
- 5 * 60
131
+ @check_name ||= self.name.underscore.split("/").last
138
132
  end
139
133
  end
140
-
141
134
  end
@@ -1,10 +1,6 @@
1
1
  if defined?(RAILS_ENV) && RAILS_ENV['test']
2
2
 
3
- Nagios.load_initializers
4
-
5
- Dir[Nagios.root + "/**/*.rb"].each do |file|
6
- require file
7
- end
3
+ Nagios.load_all
8
4
 
9
5
  module EM
10
6
  def self.defer
data/lib/nagios.rb CHANGED
@@ -80,6 +80,26 @@ module Nagios
80
80
  mutex.unlock
81
81
  end
82
82
 
83
+ def load_all
84
+ load_initializers
85
+
86
+ Dir[root + "/**/*.rb"].each do |file|
87
+ require file
88
+ end
89
+ end
90
+
91
+ def all_classes
92
+ classes = []
93
+
94
+ Nagios.constants.each do |const|
95
+ kl = eval "Nagios::#{const}"
96
+ anc = kl.ancestors rescue []
97
+ classes << kl if anc.include?(Nagios::Check) && kl != Nagios::Check && kl != Nagios::CheckEM
98
+ end
99
+
100
+ classes
101
+ end
102
+
83
103
  def url(method)
84
104
  "http://localhost:3000/nagios/check?method=#{method}"
85
105
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = %q{nagios_helper}
6
- s.version = "0.2"
6
+ s.version = "0.2.1"
7
7
 
8
8
  s.authors = ["Makarchev Konstantin"]
9
9
 
@@ -25,4 +25,4 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency "rspec"
26
26
  s.add_development_dependency "rake"
27
27
 
28
- end
28
+ end
data/spec/nagios_spec.rb CHANGED
@@ -154,4 +154,10 @@ describe "Nagios::Runner" do
154
154
  mes.should == 'msg 15'
155
155
  end
156
156
  end
157
+
158
+ it "check_name" do
159
+ c = Nagios::Tresh.new
160
+ c.check_name.should == 'tresh'
161
+ Nagios::Tresh.check_name.should == 'tresh'
162
+ end
157
163
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nagios_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makarchev Konstantin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-26 00:00:00.000000000 Z
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eventmachine
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Gem for writing, testing, executing nagios checks inside Rails application.
@@ -74,7 +74,7 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
77
+ - ".gitignore"
78
78
  - Gemfile
79
79
  - LICENSE
80
80
  - README.md
@@ -108,17 +108,17 @@ require_paths:
108
108
  - lib
109
109
  required_ruby_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '>='
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.1.4
121
+ rubygems_version: 2.2.0.rc.1
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Gem for writing, testing, executing nagios checks inside Rails application.