nagios_check 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -0
- data/lib/nagios_check/chronometer.rb +14 -0
- data/lib/nagios_check/version.rb +1 -1
- data/lib/nagios_check.rb +3 -0
- metadata +2 -1
data/README.md
CHANGED
@@ -64,6 +64,16 @@ If the value returned by `do_some_check` is between 0 and 4 inclusive the result
|
|
64
64
|
|
65
65
|
If the check method lasts more than 10 seconds, it times out and the returned value is UNKNOWN.
|
66
66
|
|
67
|
+
An alternative shorter way of writting the above check would be:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
def check
|
71
|
+
time(value_name: 'duration' do
|
72
|
+
do_some_check(options.host, options.port)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
67
77
|
License
|
68
78
|
-------
|
69
79
|
Released under the MIT License. See the [MIT-LICENSE][license] file for further details.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
|
3
|
+
module NagiosCheck
|
4
|
+
module Chronometer
|
5
|
+
def time(opts = {}, &block)
|
6
|
+
raise ArgumentError, "block is mandatory for method time" if block.nil?
|
7
|
+
time = Benchmark.realtime { block.call }
|
8
|
+
if opts[:value_name]
|
9
|
+
store_value(opts[:value_name], time)
|
10
|
+
end
|
11
|
+
time
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/nagios_check/version.rb
CHANGED
data/lib/nagios_check.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nagios_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- README.md
|
58
58
|
- Rakefile
|
59
59
|
- lib/nagios_check.rb
|
60
|
+
- lib/nagios_check/chronometer.rb
|
60
61
|
- lib/nagios_check/range.rb
|
61
62
|
- lib/nagios_check/version.rb
|
62
63
|
- nagios_check.gemspec
|