nsca 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/nsca/check.rb +21 -6
- data/nsca.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/nsca/check.rb
CHANGED
@@ -14,7 +14,7 @@ module NSCA
|
|
14
14
|
def measure &block
|
15
15
|
timeout ||= 0
|
16
16
|
exception = Class.new Timeout::Error
|
17
|
-
pd = perfdatas[perfdata_label]
|
17
|
+
pd = perfdatas[perfdata_label.to_sym]
|
18
18
|
timeout = pd.max
|
19
19
|
m = realtime do
|
20
20
|
begin
|
@@ -35,6 +35,7 @@ module NSCA
|
|
35
35
|
def min() self.class.min end
|
36
36
|
def max() self.class.max end
|
37
37
|
def to_s() "#{label}=#{value}#{unit},#{warn},#{crit},#{min},#{max}" end
|
38
|
+
def to_sym() self.class.label.to_sym end
|
38
39
|
|
39
40
|
def return_code
|
40
41
|
if @value.nil? then 3
|
@@ -71,17 +72,29 @@ module NSCA
|
|
71
72
|
def init return_code = nil, status = nil, perfdatas = nil, timestamp = nil
|
72
73
|
@return_code = return_code if return_code
|
73
74
|
@status = status if status
|
74
|
-
|
75
|
+
case perfdatas
|
76
|
+
when Hash
|
77
|
+
perfdatas.each &method( :[])
|
78
|
+
when Array
|
79
|
+
push *perfdatas
|
80
|
+
end
|
75
81
|
@timestamp = timestamp if timestamp
|
76
82
|
self
|
77
83
|
end
|
78
84
|
|
79
85
|
def [] perfdata_label
|
80
|
-
pd = @perfdatas[perfdata_label]
|
86
|
+
pd = @perfdatas[perfdata_label.to_sym]
|
81
87
|
pd && pd.value
|
82
88
|
end
|
83
89
|
|
90
|
+
def push *perfdatas
|
91
|
+
perfdatas.each {|perfdata| @perfdatas[perfdata.label] = perfdata }
|
92
|
+
@perfdatas
|
93
|
+
end
|
94
|
+
|
84
95
|
def []= perfdata_label, value
|
96
|
+
return push value if value.is_a? PerformanceData::Base
|
97
|
+
perfdata_label = perfdata_label.to_sym
|
85
98
|
cl = self.class.perfdatas[perfdata_label]
|
86
99
|
cl ||= PerformanceData::Base.new perfdata_label
|
87
100
|
@perfdatas[perfdata_label] = cl.new value
|
@@ -89,11 +102,13 @@ module NSCA
|
|
89
102
|
|
90
103
|
def text
|
91
104
|
r = "#{status || ReturnCode.find(return_code)}"
|
92
|
-
r += " | #{perfdatas.map( &:to_s).join ' '}" unless perfdatas.empty?
|
105
|
+
r += " | #{perfdatas.each_value.map( &:to_s).join ' '}" unless perfdatas.empty?
|
93
106
|
r
|
94
107
|
end
|
95
108
|
|
96
|
-
def measure
|
109
|
+
def measure perfdata_label, &block
|
110
|
+
@perfdatas[perfdata_label.to_sym].measure &block
|
111
|
+
end
|
97
112
|
def send() NSCA::send self end
|
98
113
|
|
99
114
|
def ok status = nil, perfdatas = nil
|
@@ -141,7 +156,7 @@ module NSCA
|
|
141
156
|
attr_reader :service, :hostname, :perfdatas
|
142
157
|
def init service, hostname = nil, perfdatas = nil
|
143
158
|
@service, @hostname, @perfdatas = service, hostname || `hostname -f`, {}
|
144
|
-
perfdatas.each {|pd| @perfdatas[pd.label] = pd }
|
159
|
+
perfdatas.each {|pd| @perfdatas[pd.label.to_sym] = pd }
|
145
160
|
self
|
146
161
|
end
|
147
162
|
|
data/nsca.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "nsca"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Denis Knauf"]
|
12
|
-
s.date = "2013-04-
|
12
|
+
s.date = "2013-04-09"
|
13
13
|
s.description = "Create your alerts easily and send it to Nagios"
|
14
14
|
s.email = "Denis.Knauf@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nsca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: enum
|
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
162
|
version: '0'
|
163
163
|
segments:
|
164
164
|
- 0
|
165
|
-
hash:
|
165
|
+
hash: 410259443
|
166
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
167
|
none: false
|
168
168
|
requirements:
|